3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // $a = ['item'=>['werwer'=>['tueiah'=>['auihi'=>'wieurh']]]; // $s = 'item.werwer.tueiah.auihi.wieurh'; $a = ['item'=>'werwer']; $s = 'item.werwer'; echo get($a, $s); // echo substr($s,0,strpos($s,'.'))."\n"; // echo substr($s,strpos($s,'.')+1)."\n"; function get($i, $c){ if(strpos($c,'.')){ $next = substr($s,0,strpos($s,'.')); $rem = substr($s,strpos($s,'.')+1); return get($i[$next], $rem); }else{ return $i[$c]; } }
based on TbUNX
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: s in /in/mGdHK on line 13 Notice: Undefined variable: s in /in/mGdHK on line 13 Notice: Undefined variable: s in /in/mGdHK on line 14 Notice: Undefined variable: s in /in/mGdHK on line 14 Notice: Undefined index: in /in/mGdHK on line 15
Output for 5.4.2 - 5.6.28
Notice: Undefined variable: s in /in/mGdHK on line 13 Notice: Undefined variable: s in /in/mGdHK on line 13 Notice: Undefined variable: s in /in/mGdHK on line 14 Notice: Undefined variable: s in /in/mGdHK on line 14 Notice: Undefined offset: 0 in /in/mGdHK on line 15
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/mGdHK on line 4
Process exited with code 255.