3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = (object) [ 'id' => 123, 'firstname' => 'james', 'lastname' => 'test', ]; $remapped_obj = new stdClass; foreach ($obj as $key => $value) { $remapped_obj->{$key} = "{$value}{$value}"; } $obj = $remapped_obj; var_dump($obj);
Output for 7.3.0 - 7.3.29, 7.4.0 - 7.4.21, 8.0.0 - 8.0.8
object(stdClass)#2 (3) { ["id"]=> string(6) "123123" ["firstname"]=> string(10) "jamesjames" ["lastname"]=> string(8) "testtest" }

preferences:
339.11 ms | 531 KiB | 14 Q