0

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?

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.