3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = ['a' => ['b' => 'l'], 'c' => 'm', 'd' => ['n' => 'o']]; $actionArray = ['setType' => ['b' => 'int']]; function toUpperRecursive($arr, $actionArray) { foreach ($arr as $key => $val) { if (is_array($val)) { // $newKey = strtoupper($key); $arr[$key] = toUpperRecursive($val, $actionArray); // unset($arr[$key]); } elseif (is_string($val)) { echo $key . "\n"; echo $val . "\n"; foreach($actionArray as $actionType => $keyParamArray) { echo $actionType . "\n"; // echo $foo . "\n"; foreach ($keyParamArray as $actionKey => $actionParam) { if($key === $actionKey) { switch ($actionType) { case 'setType': echo $actionParam . "\n"; $arr[$key] = $val . ' + 1111'; break; } } } } } } return $arr; } // echo "before:\n"; // var_export($testArray); // echo "after:\n"; // var_export(toUpperRecursive($testArray)); var_export(toUpperRecursive($testArray, $actionArray));
Output for git.master, git.master_jit, rfc.property-hooks
b l setType int c m setType n o setType array ( 'a' => array ( 'b' => 'l + 1111', ), 'c' => 'm', 'd' => array ( 'n' => 'o', ), )

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:
55.89 ms | 401 KiB | 8 Q