0

I have a object as shown below and i want to extract data from

stdClass Object
(
   [day1] => stdClass Object
     (
        [0] => 12.06.2015
        [part1] => Array
            (
                [0] => 19.00
                [1] => 22.00
            )

        [part2] => Array
            (
                [0] => 
                [1] => 
            )

    )
 )

How will i get date as shown above with key 0. I can get others as

$string->day1->part1[0] How can i get date "12.06.2015" ? This seems to be complicated.

JSON string for reference

 {"day1":{"0":"12.06.2015","part1":["19.00","22.00"],"part2":["",""]},"day2":{"0":"13.06.2015","part1":["09.00","12.00"],"part2":["13.00","17.00"]}} 

used json_decode to decode it.
1
  • Can you post your JSON string too? Commented May 20, 2015 at 19:43

1 Answer 1

3

You can use this:

echo $string->day1->{0};

Or my preference, decode as an array with the second argument set to true in json_decode() to use this:

echo $string['day1'][0];
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.