I don't want to use foreach loop in my code and to unset array element from the array so I tried below code but it is not working as expected.
<?php
$arr = array(array('0'=>'test','1'=>'test1','images'=>'data'),array('0'=>'test','1'=>'test1','images'=>'data'),array('0'=>'test','1'=>'test1','images'=>'data'),array('0'=>'test','1'=>'test1','images'=>'data'));
$arr1 = array_filter($arr,function ($item) use ($my_value) {
if(array_key_exists('images',$item)) {unset($item['images']);}
return $item;});
echo "<pre>";
print_r($arr1);
echo "</pre>";
die;
I want to remove key 'images' from the array but this code returns actual array.
What is the error in this code?