私のコードでforeachループを使いたくないので、配列の配列要素を配列からアンセットするので、以下のコードを試しましたが、期待通りに動作しません。配列から値をアンセットするArray_Filter
<?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;
キー 'イメージ'を配列から削除したいが、このコードは実際の配列を返す。
このコードのエラーは何ですか?