3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function createPageLlink($name,$id,$alias,$catalias){ $link = $id . "/" . $alias . "alias" . "/" . $catalias; return "<a href='" . $link . "'>" . $name . "</a>"; } $source=json_decode('[ {"parentTitle":"Winner 2009","catTitle":"Mas Muster","title":"drm202","id":"5","alias":"item1","catalias":"first"}, {"parentTitle":"Winner 2009","catTitle":"Mas Muster","title":"drm202","id":"2","alias":"item2","catalias":"first"}, {"parentTitle":"Winner 2011","catTitle":"Josh Frank","title":"A bird in the cage","id":"6","alias":"item3","catalias":"second"}, {"parentTitle":"Winner 2011","catTitle":"Josh Frank","title":"cue & repeat","id":"7","alias":"item4","catalias":"third"}]'); $result=array(); array_walk($source,function($v,$i)use(&$result){ if(!isset($result[$v->parentTitle])) $result[$v->parentTitle]=array(); if(!isset($result[$v->parentTitle][$v->catTitle])) $result[$v->parentTitle][$v->catTitle]=array(); if(!in_array($v->title,$result[$v->parentTitle][$v->catTitle])) $result[$v->parentTitle][$v->catTitle][]=$v->title; }); print_r($result); // just to debug echo "<ul>"; foreach($result as $key=>$sub){ echo "<li>".htmlentities($key,ENT_COMPAT,"UTF-8"); echo "\n<ul>"; foreach($sub as $k=>$s){ echo "<li>".htmlentities($k,ENT_COMPAT,"UTF-8"); echo "\n<ul>"; foreach($s as $i=>$v){ echo "<li>" . createPageLlink (v,?,? ). "</li>\n"; } echo "</ul>\n</li>"; } echo "</ul>\n</li>"; } echo "</ul>";
Output for 5.3.0 - 5.4.13
Parse error: syntax error, unexpected '?' in /in/A8vT1 on line 30
Process exited with code 255.