how to insert data array to another array

I want to check if the data is same then don't print the data but push that data to the first data.

for example I have data array like this:

0 => array:4 [▼
    "StartTime" => "00:00:00"
    "type" => 1
    "DateAppointment" => "2019-02-24"
    "SDay" => "Sun"
  ]
1 => array:4 [▼
    "StartTime" => "00:00:00"
    "type" => 1
    "DateAppointment" => "2019-02-25"
    "SDay" => "Mon"
  ]
2 => array:4 [▼
    "StartTime" => "00:00:00"
    "type" => 1
    "DateAppointment" => "2019-02-26"
    "SDay" => "Tue"
  ]
3 => array:4 [▼
    "StartTime" => "00:10:00"
    "type" => 1
    "DateAppointment" => "2019-02-24"
    "SDay" => "Sun"
  ]

data array 0, 1, 2 has the same StartTime, so I want my data to be like this

0 => array:10 [▼
    "StartTime" => "00:00:00"
    "type" => 1
    "DateAppointment" => "2019-02-24"
    "SDay" => "Sun"
    "type1" => 1
    "DateAppointment1" => "2019-02-25"
    "SDay1" => "Mon"
    "type2" => 1
    "DateAppointment2" => "2019-02-26"
    "SDay2" => "Tue"
  ]
1 => array:4 [▼
    "StartTime" => "00:10:00"
    "type" => 1
    "DateAppointment" => "2019-02-24"
    "SDay" => "Sun"
  ]

is that possible?

my script is like this

$interval = 10;
$hourMinInterval = 60 - $interval;
for ($i = 0; $i <= 23; $i++){
    for ($j = 0; $j <= $hourMinInterval; $j+=$interval){
    $h = sprintf('%02d',$i);
    $m = sprintf('%02d',$j);
    $clock[] = $h.':'.$m.':00';

    if ($lastdate != 'lastsunday') {
        $timestampa = $lastdate;
    } else {
        $timestampa = strtotime('last Sunday');
    }

    for($ble=0;$ble&lt;7;$ble++){
        $timeC = sprintf('%02d',$i).':'.sprintf('%02d',$j).':00';
        $tgla = strftime('%Y_%m_%d', $timestampa);
        $dateS = str_replace('_','-',$tgla);
        $sday = strftime('%a', $timestampa);
        $timeCs = array('StartTime'=&gt;$timeC, 'type'=&gt;1, 'DateAppointment'=&gt;$dateS, 'SDay'=&gt;$sday);
        $timestampa = strtotime('+1 day', $timestampa);

        if ($timeC == $timeCs['StartTime']) {
            $statusssss[] = $timeCs;
        }else{
            $statusssss[] = '';
        }
    }
}

}

If you have another way or any example with jsfiddle will be appreciated.

#php #arrays

2 Likes2.40 GEEK