0

I have an array like:

Array
(
   [name] => Linda
   [place] => stdClassObject
      {
        [country] => stdClassObject
           (
              [answer] => Spain
           )
       }
   [age] => 16
   [gender] => Array
      (
           [0] => female
      )
)

Now, I need to change the key "place" in the array in such a way that its either like:

[place] => Spain

or

[place] => Array
  (
       [0] => Spain
  )

Basically, I have to change it to the same format the other keys are in the array. Can anybody help me? I'm new to this.

2

1 Answer 1

2
$arr['place'] = $arr['place']->country->answer

or your other way:

$arr['place'] = array( $arr['place']->country->answer )
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.