3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array("count"=>10,"date"=>"2014-04-16"), array("count"=>50,"date"=>"2014-04-18"), array("count"=>80,"date"=>"2014-04-20") ); $date =array("2014-04-16","2014-04-17","2014-04-18","2014-04-19","2014-04-20"); foreach($arr as $k =>$v ){ //if(!array_key_exists($v['date'],$date)){ // $arr[]=array("count"=>0,"date"=>$date) //} $tt[]=$v['date'];$cc[]=$v['count']; $new[$v['date']]=$v["count"]; }print_r($new); //print_r(array_combine($date,$new)); //foreach($new as $k =>$v){ foreach($date as $k2 =>$v2 ){ if(!array_key_exists($v2,$new)){$new[$v2]=0;} }print_r($new); //} foreach ($new as $k => $v){ $arr2[]=array("count"=>$v,"date"=>$k); } /*foreach($arr as $k2 =>$v2 ){foreach($date as $k =>$v ){ if(!array_key_exists($v,$tt)){ $arr[]=array("count"=>0,"date"=>$v); } } }*/ print_r($arr2);die; //对应$date所有日期转换为 $arr=array( array("count"=>10,"date"=>"2014-04-16"), array("count"=>0,"date"=>"2014-04-17"), array("count"=>50,"date"=>"2014-04-18"), array("count"=>0,"date"=>"2014-04-19"), array("count"=>80,"date"=>"2014-04-20") );
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [2014-04-16] => 10 [2014-04-18] => 50 [2014-04-20] => 80 ) Array ( [2014-04-16] => 10 [2014-04-18] => 50 [2014-04-20] => 80 [2014-04-17] => 0 [2014-04-19] => 0 ) Array ( [0] => Array ( [count] => 10 [date] => 2014-04-16 ) [1] => Array ( [count] => 50 [date] => 2014-04-18 ) [2] => Array ( [count] => 80 [date] => 2014-04-20 ) [3] => Array ( [count] => 0 [date] => 2014-04-17 ) [4] => Array ( [count] => 0 [date] => 2014-04-19 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
42.74 ms | 402 KiB | 8 Q