3v4l.org

run code in 300+ PHP versions simultaneously
<?php $queryBalance=[ (object)["balance"=>"-257,21","id_month"=>12,"year"=>"2017"], (object)["balance"=>"-257,21","id_month"=>1,"year"=>"2018"], (object)["balance"=>"-257,21","id_month"=>2,"year"=>"2018"], (object)["balance"=>"166,66","id_month"=>3,"year"=>"2018"], (object)["balance"=>"55","id_month"=>12,"year"=>"2017"], //(object)["balance"=>"0","id_month"=>1,"year"=>"2018"], (object)["balance"=>"0","id_month"=>2,"year"=>"2018"], (object)["balance"=>"55","id_month"=>3,"year"=>"2018"], (object)["balance"=>"-22257,21","id_month"=>12,"year"=>"2017"], (object)["balance"=>"-64609,14","id_month"=>1,"year"=>"2018"], (object)["balance"=>"-64609,14","id_month"=>2,"year"=>"2018"], (object)["balance"=>"-12234,89","id_month"=>3,"year"=>"2018"] ]; foreach($queryBalance as $row){ $uniques[$row->year.'-'.$row->id_month]=NULL; // determine all unique date groups } while($queryBalance){ $temp=[]; foreach($uniques as $date=>$null){ $first=current($queryBalance); // cache the element that is currently first in $queryBalance $temp[]=($date==$first->year.'-'.$first->id_month) ? array_shift($queryBalance)->balance : NULL; // extract from array, or store NULL without modifying $queryBalance } $result[]=$temp; } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => '-257,21', 1 => '-257,21', 2 => '-257,21', 3 => '166,66', ), 1 => array ( 0 => '55', 1 => NULL, 2 => '0', 3 => '55', ), 2 => array ( 0 => '-22257,21', 1 => '-64609,14', 2 => '-64609,14', 3 => '-12234,89', ), )

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:
128.29 ms | 406 KiB | 5 Q