3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array( "0" => Array("CategoryID" => 3,"CategoryName" => "Test Category","Parent" => 0,"Thumb" => 0,"sort" => 8,"ArticleID" => 2,"ArticleCatgories" => "9,4,3","ArticleTitle" => "vxcvxcvx","ArticleBody" => "xcvxcvxcvxcv","InGroup" => 0,"GroupID" => 0,"Published" => 1,"PublishTime" => null,"TermID" => 11,"TermSlug" => "xcvxcvxcv","RelatedID" => 2,"TermType" => "article"), "1" => Array("CategoryID" => 4,"CategoryName" => "Test Image","Parent" => 0,"Thumb" => 0,"sort" => 4,"ArticleID" => 3,"ArticleCatgories" => "9,4,3","ArticleTitle" => "vxcvxcvx","ArticleBody" => "xcvxcvxcvxcv","InGroup" => 0,"GroupID" => 0,"Published" => 1,"PublishTime" => null,"TermID" => 11,"TermSlug" => "xcvxcvxcv","RelatedID" => 2,"TermType" => "article"), "2" => Array("CategoryID" => 9,"CategoryName" => "Test Images","Parent" => 0,"Thumb" => 7,"sort" => 2,"ArticleID" => 2,"ArticleCatgories" => "9,4,3","ArticleTitle" => "vxcvxcvx","ArticleBody" => "xcvxcvxcvxcv","InGroup" => 0,"GroupID" => 0,"Published" => 1,"PublishTime" => null,"TermID" => 11,"TermSlug" => "xcvxcvxcv","RelatedID" => 2,"TermType" => "article"), "3" => Array("CategoryID" => 4,"CategoryName" => "Test A","Parent" => 0,"Thumb" => 0,"sort" => 4,"ArticleID" => 3,"ArticleCatgories" => "9,4,3","ArticleTitle" => "vxcvxcvx","ArticleBody" => "xcvxcvxcvxcv","InGroup" => 0,"GroupID" => 0,"Published" => 1,"PublishTime" => null,"TermID" => 11,"TermSlug" => "xcvxcvxcv","RelatedID" => 2,"TermType" => "article"), "4" => Array("CategoryID" => 9,"CategoryName" => "Test B","Parent" => 0,"Thumb" => 7,"sort" => 2,"ArticleID" => 2,"ArticleCatgories" => "9,4,3","ArticleTitle" => "vxcvxcvx","ArticleBody" => "xcvxcvxcvxcv","InGroup" => 0,"GroupID" => 0,"Published" => 1,"PublishTime" => null,"TermID" => 11,"TermSlug" => "xcvxcvxcv","RelatedID" => 2,"TermType" => "article") ); $array = array_reduce( $array, function ($a, $b) { if (!isset($a[$b['ArticleID']])) { $a[$b['ArticleID']] = $b ; $a[$b['ArticleID']]['CategoryName'] = array($b['CategoryName']); } else { $a[$b['ArticleID']]['CategoryName'][] = $b['CategoryName']; } return $a; } ); var_dump($array);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [2]=> array(17) { ["CategoryID"]=> int(3) ["CategoryName"]=> array(3) { [0]=> string(13) "Test Category" [1]=> string(11) "Test Images" [2]=> string(6) "Test B" } ["Parent"]=> int(0) ["Thumb"]=> int(0) ["sort"]=> int(8) ["ArticleID"]=> int(2) ["ArticleCatgories"]=> string(5) "9,4,3" ["ArticleTitle"]=> string(8) "vxcvxcvx" ["ArticleBody"]=> string(12) "xcvxcvxcvxcv" ["InGroup"]=> int(0) ["GroupID"]=> int(0) ["Published"]=> int(1) ["PublishTime"]=> NULL ["TermID"]=> int(11) ["TermSlug"]=> string(9) "xcvxcvxcv" ["RelatedID"]=> int(2) ["TermType"]=> string(7) "article" } [3]=> array(17) { ["CategoryID"]=> int(4) ["CategoryName"]=> array(2) { [0]=> string(10) "Test Image" [1]=> string(6) "Test A" } ["Parent"]=> int(0) ["Thumb"]=> int(0) ["sort"]=> int(4) ["ArticleID"]=> int(3) ["ArticleCatgories"]=> string(5) "9,4,3" ["ArticleTitle"]=> string(8) "vxcvxcvx" ["ArticleBody"]=> string(12) "xcvxcvxcvxcv" ["InGroup"]=> int(0) ["GroupID"]=> int(0) ["Published"]=> int(1) ["PublishTime"]=> NULL ["TermID"]=> int(11) ["TermSlug"]=> string(9) "xcvxcvxcv" ["RelatedID"]=> int(2) ["TermType"]=> string(7) "article" } }

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:
165.31 ms | 409 KiB | 5 Q