-1

I need to transform an ouput value in array

I have this output

{ "ID":"5454126" ,"class":"ObjectClassRAJ" }

I just need to have the ID "5454126" how can i do it please ?

Thanks

Rp9
  • 1,955
  • 2
  • 23
  • 31
xzibit15
  • 61
  • 1
  • 2
  • 7

2 Answers2

4

Use json_decode()

$ch =json_decode($json,true);

echo $ch["ID"];

Output:-https://3v4l.org/Hsncf

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
0

Try json_decode:

<?php
$string = '{ "ID":"5454126" ,"class":"ObjectClassRAJ" }';
$obj = json_decode($string);
print_r($obj);
echo "<br>ID: ".$obj->ID;
echo "<br>class: ".$obj->class;
?>
MichaelvE
  • 2,558
  • 2
  • 9
  • 18