Ram Kumar
Ram Kumar

Reputation: 590

parsing values in a php array

I am new to PHP, please help me with the stuff. Below is the code written followed by its results. How can i access [count] inside [property] in most effective way. code

echo '<pre>';
   print_r($result);
  echo '</pre>';

output

Array
(
    [0] => Array
        (
            [property] => Array
                (
                    [href] => http://www.example.com
                    [count] => 2
                    [sample] => Array
                        (
                        )

                    [data] => Array
                        (
                            [0] => 100002067610524
                            [1] => 675985591
                        )

                    [users] => 
                    [active] => 1
                )

        )

)

Upvotes: 0

Views: 102

Answers (2)

Gaurav
Gaurav

Reputation: 28755

if you have more than one element then use this

foreach($result as $childArray)
{
    echo $childArray['property']['count'];   
}

if you have only one element in it then use

$array = $result[0]['property']['count'];

Upvotes: 2

zerkms
zerkms

Reputation: 254926

Not the most effective, but the only possible ;-)

echo $result[0]['property']['count'];

Upvotes: 3

Related Questions