Reputation: 265
I have a PHP array, and I want to define an stdClass object, and put the array into it, I want something like this:
my array is:
Array ( [0] => stdClass Object ( [subitem] => stdClass Object ( [item] => stdClass
Object ( [Label] => Customer Name [value] => value ) ) )
I want it to become:
stdClass Object (
Array ( [0] => stdClass Object ( [subitem] => stdClass Object ( [item] =>
stdClass Object ( [Label] => Customer Name [value] => Ministry of Finance /
Ramallah ) ) )
)
Any help?
Upvotes: 0
Views: 258
Reputation: 790
You cannot assing array to class you can assing it to class variable.
for example
$yourArray = array();
$yourObject = new \stdClass();
$yourObject->yourVar = $yourArray;
But i do not know if it is what you want achieve?
Upvotes: 1