-2

I have the following array:

Array (
    [result] => Array (
        [id] => 58fba3ebf4
        [type] => A
        [name] => ser.domain.com
        [content] => 192.168.100.1
        [proxiable] => 
        [proxied] => 
        [ttl] => 1 
        [priority] => 10 
        [locked] => 
        [zone_id] => eb0d86828e3ac837c 
        [zone_name] => domain.com 
        [modified_on] => 2018-07-06T06:37:14.069598Z
        [created_on] => 2018-07-06T06:37:14.069598Z
        [meta] => Array (
            [auto_added] => 
            [managed_by_apps] => 
            [managed_by_argo_tunnel] => 
        )
    )
    [success] => 1
    [errors] => Array ( )
    [messages] => Array ( )
)

How can I just get the value from id?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
  • 3
    What have you tried? Maybe `$arrays['result']['id']`? A good [read](https://www.w3schools.com/php/php_arrays.asp) – hungrykoala Jul 06 '18 at 06:41
  • 6
    Possible duplicate of [How can I access an array/object?](https://stackoverflow.com/questions/30680938/how-can-i-access-an-array-object) – mickmackusa Jul 06 '18 at 06:48
  • @AramGrigoryan Please avoid posting solutions as comments. Posting solutions as comments does several bad things to StackOverflow including 1. Question Abandonment by the OP, 2. Bad page content -- whereby future researchers have to look in multiple sections of the page to find "solutions". – mickmackusa Jul 06 '18 at 06:54
  • @hungrykoala Please avoid posting solutions as comments. Posting solutions as comments does several bad things to StackOverflow including 1. Question Abandonment by the OP, 2. Bad page content -- whereby future researchers have to look in multiple sections of the page to find "solutions". – mickmackusa Jul 06 '18 at 06:54
  • @KENNETH I have downvoted because the downvote hint-text says: "_This question does not shows any research effort_" – mickmackusa Jul 06 '18 at 06:55
  • I thought this would be closed as this is a question that should be common knowledge. I'm sure a duplicate of this exists in SO as well. I mean a lot of dupes. – hungrykoala Jul 06 '18 at 06:56
  • I agree, but you didn't voted to close, right? – mickmackusa Jul 06 '18 at 06:56
  • I was going to but it slipped my mind. I even forgot I commented here. I'll remember to flag after commenting next time. – hungrykoala Jul 06 '18 at 06:57

3 Answers3

0
$data =json_decode($response);

  $id = $data->result->id;

Assuming your payload from the request was $response.

Toby Okeke
  • 624
  • 3
  • 13
  • Code-only answer are low-value on StackOverflow. Everytime you post an answer, do so with the intent to educate the OP and thousands of future researchers who may not know how your solution works or why it is a good idea. – mickmackusa Jul 06 '18 at 06:49
0

Here is solution

// $result_array() is your reponse from curl PHP

$data = $result_array();

$id = $data['result']['id'];

Sanjay Kumar
  • 424
  • 5
  • 15
  • 1
    Code-only answer are low-value on StackOverflow. Everytime you post an answer, do so with the intent to educate the OP and thousands of future researchers who may not know how your solution works or why it is a good idea. – mickmackusa Jul 06 '18 at 06:49
0

You already have a multi-dimensional array so just try like this

echo $arrays['result']['id']; // this will return id
echo $arrays['result']['type']; // this will return type
A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103