3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $map = ' \\ / / / / / \\ \\ \\ / \\ /\\ \\/ \\ / \\ \\ \\ \\ \\ \\ / /'; var_dump( r($map)); function r($m){ $z=strpos($m,"/\\"); $z-=strrpos(substr($m,0,$z),"\n"); $ls=explode("\n",$m);$i=0; $a=[1=>0,2=>0,3=>0,4=>0]; foreach($ls as $l){ $y=$i<count($ls)/2?0:1;echo $y+1+($y?2:1); // $s = substr($l,0,$z-1); // $a[$y+0+$y?2:1]++;//[] = strpos($s,"/")?"/":(strpos($s,"\\")?"\\":""); // $s = substr($l,$z); // $a[$y+1+$y?2:1]++;//[] = strpos($s,"/")?"/":(strpos($s,"\\")?"\\":"");; $i++; } return $a; }
based on Wtr0A
Output for 5.4.2 - 7.2.0
2222222444444array(4) { [1]=> int(0) [2]=> int(0) [3]=> int(0) [4]=> int(0) }
Output for 5.3.18 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/0DHOZ on line 21
Process exited with code 255.