3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array_1 = array( 'apple'=>1,'banana'=>2,'coconut'=> 3); $array_2 = array( 'apple'=>2,'banana'=>3,'coconut'=> 4); foreach( $array_1 as $fruit => $num) { if(array_key_exists($fruit, $array_2)){ //check if key from array_1 exists in array_2 $final_array[] = $fruit => $array_1[$fruit].','.$array_2[$fruit]; //concatenate values from shared key } } print_r (final_array);
Output for 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /in/dSUnW on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_DOUBLE_ARROW in /in/dSUnW on line 8
Process exited with code 255.