jafarsalam Posted January 13, 2008 Share Posted January 13, 2008 hi; i have : echo '<pre>'; print_r($response); echo '</pre>'; and response is : Net_Ping_Result Object ( [_icmp_sequence] => Array ( [1] => 183 [2] => 158 [3] => 180 ) [_target_ip] => 209.35.123.XXX [_bytes_per_request] => 64 [_bytes_total] => 192 [_ttl] => 48 [_raw_data] => Array ( [0] => PING xxxxxxxxxx.com (209.35.123.XXX) 56(84) bytes of data. [1] => 64 bytes from xxxxxxxxxx.com (209.35.123.XXX): icmp_seq=1 ttl=48 time=183 ms [2] => 64 bytes from xxxxxxxxxx.com (209.35.123.XXX): icmp_seq=2 ttl=48 time=158 ms [3] => 64 bytes from xxxxxxxxxx.com (209.35.123.XXX): icmp_seq=3 ttl=48 time=180 ms [4] => [5] => --- xxxxxxxxxx.com ping statistics --- [6] => 3 packets transmitted, 3 received, 0% packet loss, time 2000ms [7] => rtt min/avg/max/mdev = 158.377/173.917/183.278/11.070 ms ) [_sysname] => linux [_round_trip] => Array ( [min] => 158.377 [avg] => 173.917 [max] => 183.278 [stddev] => 11.07 ) [_transmitted] => 3 [_received] => 3 [_loss] => 0 ) How can i print only [3] => 64 bytes from xxxxxxxxxx.com (209.35.123.XXX): icmp_seq=3 ttl=48 time=180 ms and [avg] => 173.917 thank for any help ! jeff Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/ Share on other sites More sharing options...
revraz Posted January 13, 2008 Share Posted January 13, 2008 echo $response['_raw_data'][3]; echo $response['min']['avg']; If that doesn't work, at least you can see how to get what you need. Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/#findComment-437767 Share on other sites More sharing options...
jeremywesselman Posted January 13, 2008 Share Posted January 13, 2008 You need to drill down through the multi-dimensional array. echo $response['_raw_data'][3] Just use the array keys to get their values. I'll let you get the avg because I can't really tell the path to it. EDIT: I tried to review, but pressed the button too quickly Jeremy Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/#findComment-437768 Share on other sites More sharing options...
jafarsalam Posted January 13, 2008 Author Share Posted January 13, 2008 hi guys; I tried the echo $response['_raw_data'][3]; echo $response['min']['avg']; the it does not print anything . ??? Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/#findComment-437791 Share on other sites More sharing options...
cooldude832 Posted January 13, 2008 Share Posted January 13, 2008 by design print_R is a debugging fuction to output a variable in a format easy to view (mostly on arrays) to get single array nodes say <?php echo $myarray['NodeNumber or Name']; ?> Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/#findComment-437793 Share on other sites More sharing options...
Hypnos Posted January 13, 2008 Share Posted January 13, 2008 $response looks like an object, not an array. So, shouldn't it be something like $response->_raw_data[3]... Can you show how you're getting $response? Link to comment https://forums.phpfreaks.com/topic/85769-php-print_r/#findComment-437797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.