3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $payload = '{ "params": { "nome": "jacopo", "cognome": "jacopo", "city.id": 1 } }'; $payload = json_decode($payload); if (is_object($payload->params)) { $v = $payload->params; foreach ($v as $key => $value) { if (strpos($key, '.') === false) { $newKey = '_x.' . $key; unset($v->{$key}); } else { $newKey = $key; } $v->{$newKey} = $value; } print_r($v); }
based on HV53W
Output for 5.2.0 - 7.2.0
stdClass Object ( [city.id] => 1 [_x.nome] => jacopo [_x.cognome] => jacopo )
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/VfbJu on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/VfbJu on line 9
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/VfbJu on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/VfbJu on line 9