I encountered some strange error with array_filter.
My json data looks like this:
{
"data": [
{
"item": "book",
"date": "9.10."
},
{
"item": "apple",
"date": "10.10."
},
{
"item": "pen",
"date": "11.10."
}
]
}
I can remove some objects with this code:
$days_arr = array('9.10.','10.10.');
$result['data'] = array_filter($my_var['data'], function($v) use ($days_arr)
{
return in_array($v['date'], $days_arr);
});
return json_encode($result);
Which removes the objects containing a date = 9.10. and 10.10.
But the problem: as soon as I use $days_arr = array('9.10.','11.10.');
My output is this:
{
"data": {
"0": {
"item": "book",
"date": "9.10."
},
"1": {
"item": "pen",
"date": "11.10"
}
}
}
So as you can see, some very strange error happens, the json is completely wrong formatted. 9.10. and 10.10. works, 10.10. and 11.10. destroys the output.
Who can help?