thinkphp5.0 分页回调处理each方法有错误

TP5,each方法代码 thinkphp/library/think/Collection.php (each)

/**
     * 给每个元素执行个回调
     *
     * @param  callable $callback
     * @return $this
     */
    public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
              if ($callback($item, $key) === false) {
                break;
            }
        }        
        return $this;
    }


foreach 内对$this 没有影响;

修改代码:

public function each(callable $callback)
    {
        foreach ($this->items as $key => $item) {
            $this->items[$key] = $callback($item, $key);
            if ($callback($item, $key) === false) {
                break;
            }
        }
        
        return $this;
    }



有疑问的可以加群162092974咨询


你可能感兴趣的:(thinkphp,php)