0

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
 )
 )
)
Charles
51.5k13 gold badges107 silver badges146 bronze badges
asked Mar 21, 2011 at 6:33

2 Answers 2

3

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

echo $result[0]['property']['count'];
answered Mar 21, 2011 at 6:35
2

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'];
Sander Marechal
23.3k13 gold badges69 silver badges96 bronze badges
answered Mar 21, 2011 at 6:35
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.