Please check with following code
$source=array(
"0" => array( "status_change" => "start", "clock_status" => "1" ),
"1" => array( "status_change" => "stop", "clock_status" => "2" ),
"2" => array( "status_change" => "stop", "clock_status" => "2" ),
"3" => array( "status_change" => "stop", "clock_status" => "2" ),
"4" => array( "status_change" => "stop", "clock_status" => "2" ),
"5" => array( "status_change" => "stop", "clock_status" => "2" ),
"6" => array( "status_change" => "stop", "clock_status" => "2" ),
"7" => array( "status_change" => "start", "clock_status" => "1" ),
"8" => array( "status_change" => "stop", "clock_status" => "2" ),
"9" => array( "status_change" => "start", "clock_status" => "1" ),
"10" => array( "status_change" => "start", "clock_status" => "1" ),
"11" => array( "status_change" => "start", "clock_status" => "1" ),
"12" => array( "status_change" => "start", "clock_status" => "1" )
);
function reduce_successive(&$source) {
$prev_status="none";
foreach($source as $key=>$item) {
if($item['status_change'] == $prev_status) {
unset($source[$key]);
} else {
$prev_status = $item['status_change'];
}
}
}
reduce_successive($source);
var_dump( $source );
solved Removing duplicates entries from a multidimensional php array [duplicate]