3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array=array('Fieldname1:value;Filedname2:value;Fieldname3:value', 'Fieldname1:value;Filedname2:value;Fieldname3:value', 'Fieldname1:value;Filedname2:value;Fieldname3:value',); $arr = array(); foreach ($array as $line) { $str = explode(';', $line); foreach( $str as $strPair ) { list($key, $value) = explode(':', $strPair); $tmpArr[$key]= $value; } $arr[] = tmpArr; } var_dump($arr);
Output for 7.2.0
Warning: Use of undefined constant tmpArr - assumed 'tmpArr' (this will throw an Error in a future version of PHP) in /in/SmHG5 on line 12 Warning: Use of undefined constant tmpArr - assumed 'tmpArr' (this will throw an Error in a future version of PHP) in /in/SmHG5 on line 12 Warning: Use of undefined constant tmpArr - assumed 'tmpArr' (this will throw an Error in a future version of PHP) in /in/SmHG5 on line 12 array(3) { [0]=> string(6) "tmpArr" [1]=> string(6) "tmpArr" [2]=> string(6) "tmpArr" }
Output for 5.3.19 - 7.1.10
Notice: Use of undefined constant tmpArr - assumed 'tmpArr' in /in/SmHG5 on line 12 Notice: Use of undefined constant tmpArr - assumed 'tmpArr' in /in/SmHG5 on line 12 Notice: Use of undefined constant tmpArr - assumed 'tmpArr' in /in/SmHG5 on line 12 array(3) { [0]=> string(6) "tmpArr" [1]=> string(6) "tmpArr" [2]=> string(6) "tmpArr" }