我有一个PHP数组,我想定义一个stdClass对象,并将数组放入其中,我想要这样的东西:
我的数组是:
Array ( [0] => stdClass Object ( [subitem] => stdClass Object ( [item] => stdClass
Object ( [Label] => Customer Name [value] => value ) ) )
我希望它成为:
stdClass Object (
Array ( [0] => stdClass Object ( [subitem] => stdClass Object ( [item] =>
stdClass Object ( [Label] => Customer Name [value] => Ministry of Finance /
Ramallah ) ) )
)
任何帮助?
答案 0 :(得分:1)
您无法将数组分配给类,您可以将其分配给类变量。
例如
$yourArray = array();
$yourObject = new \stdClass();
$yourObject->yourVar = $yourArray;
但我不知道这是否是你想要达到的目标?