3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = "[1,1x,1x,1x][2,2x,2x,2x]"; $arr ="[]"; preg_replace_callback('/\[(.*?)\]/', function($m) use (&$arr){ $arr[] = explode(',',preg_replace('/([\w]+)/', "[$1]", $m[1])); }, $str); print_r($arr); var_dump($arr);
based on MAO5h
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: [] operator not supported for strings in /in/lY5Nn:6 Stack trace: #0 [internal function]: {closure}(Array) #1 /in/lY5Nn(7): preg_replace_callback('/\\[(.*?)\\]/', Object(Closure), '[1,1x,1x,1x][2,...') #2 {main} thrown in /in/lY5Nn on line 6
Process exited with code 255.
Output for 5.3.20 - 5.6.28
Fatal error: [] operator not supported for strings in /in/lY5Nn on line 6
Process exited with code 255.