3

I have an array which contains an number of array objects. Is there a way to insert something in the array object for example [d] = value4 in array object [0]?

   Array ( [0] => stdClass Object ( 
                    [a] => value1 
                    [b] => value2 
                    [c] => value3 )

   [1] => stdClass Object ( 
                    [a] => value1 
                    [b] => value2 
                    [c] => value3 )
    )

2 Answers 2

9

You mean like:

$thearray[0]->d = 'value4';

??

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

2 Comments

How do I echo say value3? I'm having a lot of greif over array objects.
@user971824: echo $thearray[0]->c;
0

This should do the trick:

$array[0]->d = 'value4';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.