如何在查找结果数组中下降多个级别


How to descend several levels in find results array

在我的桌子上调用 Cake 的查找方法,如下所示:

$this->Client->find('all',['recursive' => -1])

返回

array(
(int) 0 => array(
    'Client' => array(
        'id' => '1',
        'name' => 'Intel Corporation',
        'website' => 'www.intel.com',
        'address' => '2200 Mission College Blvd.',
        'city' => 'Santa Clara',
        'state' => 'CA',
        'zip' => '95054'
    )
),
(int) 1 => array(
    'Client' => array(
        'id' => '3',
        'name' => 'Motorola Mobility LLC',
        'website' => 'www.motorola.com',
        'address' => '222 W. Merchandise Mart Plaza',
        'city' => 'Chicago',
        'state' => 'IL',
        'zip' => '60654'
    )
),
(int) 2 => array(
    'Client' => array(
        'id' => '4',
        'name' => 'Nokia',
        'website' => 'www.nokia.com',
        'address' => '6000 Connection Drive',
        'city' => 'Irving',
        'state' => 'TX',
        'zip' => '75039'
    )
),)

我想要的是删除多余的"客户端"数组级别:

array(
(int) 0 => array(
    'id' => '1',
    'name' => 'Intel Corporation',
    'website' => 'www.intel.com',
    'address' => '2200 Mission College Blvd.',
    'city' => 'Santa Clara',
    'state' => 'CA',
    'zip' => '95054'
),
(int) 1 => array(
    'id' => '3',
    'name' => 'Motorola Mobility LLC',
    'website' => 'www.motorola.com',
    'address' => '222 W. Merchandise Mart Plaza',
    'city' => 'Chicago',
    'state' => 'IL',
    'zip' => '60654'
),
(int) 2 => array(
    'id' => '4',
    'name' => 'Nokia',
    'website' => 'www.nokia.com',
    'address' => '6000 Connection Drive',
    'city' => 'Irving',
    'state' => 'TX',
    'zip' => '75039'
),

);

我想在原生 Cake 中用参数调用或其他东西来做到这一点,但是如果我必须在 php 数组函数中执行此操作,请解释一下。 它基本上是用于分页的数据。

这就是蛋糕的做法。

您确定甚至有必要移动内部数组吗?您可以按原样使用它...

无论如何,移动内部数组是相当微不足道的:

foreach ($clients as & $client) {
    $client = $client['Client'];
}