我们使用了 collect 函数从数组中创建新的集合实例,对其中的每个元素运行 strtoupper 函数之后再移除所有的空元素
$collection = collect(['pinux', 'php...[[1, 2, 3, 4], [5, 6, 7]]
#这个方法比较适用在使用网格系统时的视图中,如 Bootstrap。...collection->except(['price', 'discount']);
$filtered->all(); // ['product_id' => 1]
#15.filter方法,使用给定的回调函数过滤集合的内容...#21.forPage方法,返回给定页码上显示的项目的新集合。这个方法接受页码#作为其第一个参数和每页显示的项目数作为其第二个参数。...如果指定的键不存在,就会返回回调的结果:
$collection = collect(['name' => 'taylor', 'framework' => 'laravel']);
$collection