3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function reduceMultidimensionalArraysToOneDimension(array &$result, array $messages, $preffix) { foreach ($messages as $field => $msg) { if (is_array($msg)) { reduceMultidimensionalArraysToOneDimension($result, $msg, $preffix . $field . '_')); } else { $result[$preffix . $field] = $msg; } } } $messages = array( 'second1' => array( 'm1' => 'lorem ipusum', 'third1' => array( 'm1' => 'lorem ipusum', 'm2' => 'lorem ipusum', ), 'm2' => 'lorem ipusum', 'm3' => 'lorem ipusum', 'third2' => array( 'm1' => 'lorem ipusum', 'm2' => 'lorem ipusum', ), 'm4' => 'lorem ipusum', ), 'm1' => 'lorem ipusum', 'second2' => array( 'm1' => 'lorem ipusum', 'third1' => array( 'm1' => 'lorem ipusum', 'm2' => 'lorem ipusum', ), 'm2' => 'lorem ipusum', 'm3' => 'lorem ipusum', 'third2' => array( 'm1' => 'lorem ipusum', 'm2' => 'lorem ipusum', ), 'm4' => 'lorem ipusum', ), 'm2' => 'lorem ipusum', ); echo "Starting reference\n"; $time = microtime(true); reduceMultidimensionalArraysToOneDimension($result, $messages, 'preffix_'); $time = microtime(true) - $time; echo 'reference() took ' . $time . " seconds\n";
Output for 5.3.0 - 5.4.27
Parse error: syntax error, unexpected ')' in /in/c4l18 on line 7
Process exited with code 255.