dongliang1893 2018-03-26 14:00
浏览 34
已采纳

无法在php中使用数组映射函数

array_map() expects parameter 1 to be a valid callback, class 'Search' does not have a method 'wishList'

 $shops = array_map(array($this, 'wishList'), $shops);

 function wishList($shops) {
        print_r(shops);
        $this->check_authentication(); 
        $user = $this->getUser();
        $shops->isWishList = $this->Wishlist_model->_isShopInMyWishList($shops->id, $user->id,6) ? true : false;
        return $shops;
    }
  • 写回答

1条回答 默认 最新

  • doujiangqu2823 2018-03-26 14:04
    关注

    For what I see that's the issue, you just declared your wishList function not in the Search class, if you wanna do this your should write this:

    $shops = array_map('wishList', $shops);
    

    Or move you wishList function to your Search class

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办