3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $row = new stdClass; $field_name = 'field_my_field'; $delta = 0; $row->$field_name = []; $row->$field_name[$delta] = 'value'; // This works just fine. $f = $field_name . ':title'; $row->$f = []; $row->$f[$delta] = 'value'; // This doesn't work. var_dump($row);
based on 6S1nV
Output for 7.0.0 - 7.2.0
object(stdClass)#1 (2) { ["field_my_field"]=> array(1) { [0]=> string(5) "value" } ["field_my_field:title"]=> array(1) { [0]=> string(5) "value" } }
Output for 5.4.9 - 5.6.28
object(stdClass)#1 (3) { ["field_my_field"]=> array(0) { } ["f"]=> string(5) "value" ["field_my_field:title"]=> array(0) { } }
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/dX9OJ on line 6
Process exited with code 255.