0

I have an array that I have run json_decode on it...

How can I echo the category_name Hoops from $myarray?

The following is the output of

echo"<pre>;
print_r($myarray);
echo"</pre>;
Array
(
    [Althetic] => Array
        (
            [0] => Array
                (
                    [category_id] => 1
                    [category_name] => Balls
                    [parent_id] => 0
                )

            [1] => Array
                (
                    [category_id] => 2
                    [category_name] => Hoops
                    [parent_id] => 0
                )

            [2] => Array
                (
                    [category_id] => 3
                    [category_name] => Strings
                    [parent_id] => 0
                )

        )

    [rawRequest] => Hello world
    [hasError] => 1
    [errorMessage] => OK
)

I tried

echo $myarray[Althetic][1]->[category_name];

Without any results :(

T

1 Answers1

-1

This is a multidimensional array, -> is used to access elements of object.

$myarray['Althetic'][1]['category_name'];
SelVazi
  • 10,028
  • 2
  • 13
  • 29