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;
    }

图片转代码服务由CSDN问答提供 功能建议

array_map()期望参数1是有效的回调,类“搜索”没有方法'wishList'

  $ shops = array_map(array($ this,'wishList'),$ shops); 
 
函数wishList($ shops){
 print_r(商店)  ; 
 $ this-> check_authentication();  
 $ user = $ this-> getUser(); 
 $ shops-> isWishList = $ this-> Wishlist_model-> _isShopInMyWishList($ shops-> id,$ user-> id,6)  ?  true:false; 
返回$ 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

    点赞 打赏 评论

相关推荐 更多相似问题