3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ 'key1' => [ 'first string' ], 'key2' => [ 'second array' ] ]; $array2 = [ 'key1' => [ 'new string from second array' ], 'key2' => [ 'second key in this other multidimensional array' ] ]; $outer_string = "Hello, this is my first string\nAnd here you can see another string from my second array"; $replacements = array(); foreach ($array1 as $k => $v) { $replacements[$v[0]] = $array2[$k][0]; } echo strtr($outer_string, $replacements);
Output for git.master, git.master_jit, rfc.property-hooks
Hello, this is my new string from second array And here you can see another string from my second key in this other multidimensional array

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
146.39 ms | 405 KiB | 5 Q