3v4l.org

run code in 300+ PHP versions simultaneously
<?php $convert_html_keys = array("name", "label", "html", "options" => array("text")); $object = json_decode(json_encode(array( "options" => array( 0 => json_decode(json_encode(array( "value" => 0, "text" => "wtf0000" ))), 1 => json_decode(json_encode(array( "value" => 1, "text" => "wtf1111" ))) ) ))); foreach ($convert_html_keys as $key => $val) { foreach ($val as $option_array_value) { foreach ($object->$key as &$object_key_value) { $object_key_value->text = "omg"; } } } print_r($object);

preferences:
112.42 ms | 402 KiB | 5 Q