Cake Cake和MVC的新手,我在Cake book中给出的集合的read this 教程。当我从Controller(示例代码)调用此代码时,它返回
Cake \ Collection \ Collection Object()
这应该像[2,3,1]
那样实际返回请纠正我,如果我错误地返回了代码或者遗漏了任何命名空间
示例代码
<?php
namespace App\Controller;
use Cake\ORM\TableRegistry;
use Cake\Collection\Collection;
class AdminController extends AppController
{
public function collection()
{
$items = ['a' => 1, 'b' => 2, 'c' => 3];
$collection = new Collection($items);
// This could return [2, 3, 1]
$collection->shuffle()->toArray();
print_r($collection); exit;
}
}
?>