0

I have this response from an API request.

object(stdClass)#28 (3) { 
   ["Success"]=> bool(true) 
   ["Message"]=> string(0) "" 
   ["Invoice"]=> object(stdClass)#29 (4) { 
       ["Number"]=> string(6) "2313123" 
       ["Series"]=> string(2) "SM" 
       ["Link"]=> string(22) "https://randomlinkhere" 
       ["LinkPlata"]=> NULL 
   } 
}

To get this response i use :

$context  = stream_context_create($request);
$result = file_get_contents($url, false, $context);

if ($result === FALSE) { /* Handle error */ }

var_dump(json_decode($result));

Now i'm trying to read the response. I need to read

["Link"]=> string(133) "https://randomlinkhere"

I need to get only that Link to a variable, like $variable = https://randomlinkhere

["Series"]=> string(2) "SM"

I need to get only that Series to a variable, like $variable = SM

I tried alot of things, nothing work.

My best result was with this :

$myArray = explode(',', $result);
print_r($myArray[4]); 

Wich is giving me the next result :

"Link":"https://randomlinkhere"
Barmar
  • 741,623
  • 53
  • 500
  • 612
Vlad.G
  • 1
  • 2

0 Answers0