Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.