- json_decode: documentation ( source)
- print_r: documentation ( source)
- json_encode: documentation ( source)
<?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);