I have some difficulties to explain my problem, some code is better than a long text:
<?php
$n = new stdClass();
$f = 'field[0][0]';
$n->$f = 1;
var_dump($n);
The current result:
object(stdClass)#1 (1) {
["field[0][0]"]=>
int(1)
}
The desired result:
object(stdClass)#1 (1) {
["field"]=>
array(1) {
[0]=>
array(1) {
[0]=>
int(1)
}
}
}
Is it possible?
Thank's in advance.
eval('$n->'.$f.'=1;');
additional to this,
please check $f
is from TRUSTABLE source
How about using:
$n = new stdClass();
$f = 'field';
$n->$f = array(array(1));
var_dump($n);
$n = new stdClass();
$f = 'field';
$n->$f = array(array(1));
var_dump($n);
object(stdClass)#1 (1) { ["field"]=> array(1) { [0]=> array(1) { [0]=> int(1) } } }