I'm trying to unset some elements of JSON Array, so if pname value start with XX it should unset. Normal JSON String gives me this
$json = str_replace('"', '"', $loc);
[{"uid":"352","pcode1":"AB1","pname":"XXAB1"},....}]
If I hardcode pname value like this
foreach ($json as $key => $value)
{
if (in_array('XXAB1', $value)) {
unset($json[$key]);
}
}
$j = json_encode($json);
echo $j;
it works unsets that array but how can I do this dynamically ? So that each pname value begins with XX can be unsets.