Syed Alish Raza Naqvi Syed Alish Raza Naqvi - 4 years ago 124
PHP Question

Get Specific Value From Json array in PHP

I'm Try To Access Some specific Value From Return JSON

Real Value is

79#45#597#10#10#10000#M


$retframe = str_ireplace('#',',', $stframe);
echo json_encode(array( 'Value' => $retframe));
///Output Response Back is
{"Value":"79,45,597,10,10,10000,M"}


I Want to Get Only Value of
79,597,10

Answer Source

if you want to get 79,597,10 values statically than you will do it like this way.

$retframe = str_ireplace('#',',', $stframe);//$retframe = '79,45,597,10,10,10000,M';
$rs = explode(",",$retframe);
$array[] = $rs[0];
$array[] = $rs[2];
$array[] = $rs[3];
$array1= implode(",", $array);
echo json_encode(array( 'Value' => $array1));

and you will get result like this : {"Value":"79,597,10"}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download