Recently, I was working with some JSON decoded into a PHP array, and I needed to remove an item from the associative array. With only the value
Recently, I was working with some JSON decoded into a PHP array, and I needed to remove an item from the associative array. With only the value, I wasn’t sure how to remove it, and here was the code I used.
foreach($arr['category'] as $key => $value) {
if (in_array('item_to_remove', $value)) {
unset($arr['category'][$key]);
}
}
0 comments:
Post a Comment