I have string like this:
$filters= {"DestinationZone":"","date":"2019-12-13","PolicyName":"","CloseReason":"","ApplicationName":"","level":"","Host":""}
I want to go through this string and divide it to key and value
I tried a lot but I don't know why it does not want to work.
this is the code which I tried
$filters=str_replace('{','', $filters);
$filters=str_replace('}','', $filters);
$filters=explode(',',$filters);
for($i=0;$i<count($filters);$i++){
$xx=explode(':',$filters[$i]);
var_dump($xx);
foreach ($xx as $xx)
{ $value=trim($xx,'"');
var_dump($value);
// $key=trim($key,'"');
if (!empty($value)) {
//$query->where("$key", '=', "$value");
}
}
}
I think this code is very mess , I am using laravel