title: Php check and replace if value exist in multi array?
body: <p><strong>Problem:</strong></p>
  
  <p><em>I dont know/understand how to check if date and place exists on the same "row" and they exists more then once.
  Second, how do i then merge an array
  my case MergeArray with ArraySchedule</em></p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>$ArraySchedule = array();
  while ($data = $stmt -&gt; fetch(PDO::FETCH_ASSOC)) {
  
      $schedules = array(
          "id" =&gt; $data['id'],
          "name" =&gt; $data['name'],
          "date" =&gt; $data['date'],
          "time" =&gt; $data['time'],
          "place_id" =&gt; $data['place_id'],
          "place" =&gt; $data['place'],
  
  
      );
      array_push($ArraySchedule, $schedules);
  
  }
  $dupe_array = array();
  foreach ($ArraySchedule as $key =&gt; $value) {
     if(++$dupe_array[$value["date"]] &gt; 1 &amp;&amp; ++$dupe_array[$value["place_id"]] &gt; 1 ){
      // this statement is wrong, i want something like: 
      // if date and place_id exists on the same "row" and they exists more then once 
   }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>What i want to do:</strong></p>
  
  <p><em>Check if ArraySchedule contains schedules that have the same date and place,
  if there is more than one schedule that has the same date and place_id.
  then I want to update ArraySchedule with this structure</em></p>
  
  <pre><code>$MergeArray = array(
          "id" =&gt; ArraySchedule['id'],
          "name" =&gt; array(
              "name" =&gt; scheduleSameDateAndPlace['name'],
              "name" =&gt; scheduleSameDateAndPlace['name'],
              "name" =&gt; scheduleSameDateAndPlace['name'],
          ),
          "date" =&gt; $ArraySchedule['date'],
          "time" =&gt; $ArraySchedule['time'],
          "place_id" =&gt; $ArraySchedule['place_id'],
          "place_name" =&gt; $ArraySchedule['place_name'],
      ),
  </code></pre>
  
  <p><em>MergeArray with ArraySchedule? 
  anyway...</em> </p>
  
  <p><strong>Output I think I want?</strong></p>
  
  <pre><code>Print_r($ArraySchedule) 
          array(
              [0] =&gt; 
                  array(
                      [id] =&gt; 1 
                      [names] =&gt; Simon 
                      [date] =&gt; 2019-01-02 
                      [time] 18.00 
                      [place_id] =&gt; Tystberga Park 
                      [place] =&gt; Tystberga
                  )
              [1] =&gt; 
                  array(
                      [id] =&gt; 2 
                      //[names] insted of [name]?
                      [names] =&gt; 
                          array(
                              [name] =&gt; Vincent 
                              [name] =&gt; Angel 
                              [name] =&gt; Kim
                          )
                      [date] =&gt; 2019-02-17
                      [time] =&gt; 13.00
                      [place_id] =&gt; Borås Park
                      [place] =&gt; Borås
                  )
              [2] =&gt; 
                  array(
                      [id] =&gt; 3
                      // [names] is always an array?
                      [names] =&gt; Caitlyn 
                      [date] =&gt; 2019-03-15 
                      [time] 13.00 
                      [place_id] =&gt; Plaza Park 
                      [place] =&gt; EvPark
                  )
          ) 
  </code></pre>