%77w%77%2Ef%6F%72p%73%70%2Ec%6E
写php 代码的时候 遇到个问题,就是对数组数据的 批量处理,有写循环处理的也有用函数处理的
在实际应用中出现了 Error: Call to a member function map() on array
 
如果是 对象数组,在laravel中用到
$data= $old_data->map(function ($tempdata) {
            $tempdata->spare_url = str_replace(old,new, $tempdata->spare_url);
            return $tempdata;
        });
后来 数组处理
$data= $old_data->map(function ($tempdata) {
            $tempdata'‘spare_url'] = str_replace(old,new, $tempdata['spare_url']);
            return $tempdata;
        });
结果出现错误 Error: Call to a member function map() on array
 
正确的应该是:
$data= array_map(function ($tempdata) {
            $tempdata['spare_url'] = str_replace(old,new, $tempdata['spare_url']);
            return $tempdata;
        },$old_data);
 

http://%77%77%77%2E%66%6F%72%61%73%70%2E%63%6E