3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeAndBoolify($posted) { $result = []; foreach ($posted as $key1 => $value1) { if ($key1 === 'JsonData') { foreach (json_decode($value1, true) as $item) { foreach ($item as $key2 => $value2) { if (in_array($value2, ['true', 'false'])) { $value2 = json_decode($value2); } $result[$key2] = $value2; } } } else { $result[$key1] = $value1; } } return $result; } $_POST = [ 'JsonData' => '[{"firstname":"false"},{"lastname":"true"},{"email":""}]', 'otherdata' => 'otherdata' ]; var_export(mergeAndBoolify($_POST));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'firstname' => false, 'lastname' => true, 'email' => '', 'otherdata' => 'otherdata', )

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