次の配列構造がありますが、これをどのように処理すれば、change_status の連続した発生をすべて削除できますか。以下の配列を見て、私が達成したいことを確認してください。
$a=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" )
);
上記の配列を処理した後、次のようにしたいと思います
$a=array(
"0" => array( "status_change" => "start", "clock_status" => "1" ),
"1" => 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" )
);
どんなアイデアでも大歓迎です。私は一次元配列を扱うコードを持っていますが、これは私を混乱させ、配列を扱うときは少し遅いです。