Php 如何在查找结果数组中降低多个级别
在我的表上调用Cake的find方法,如下所示:Php 如何在查找结果数组中降低多个级别,php,arrays,cakephp-2.0,Php,Arrays,Cakephp 2.0,在我的表上调用Cake的find方法,如下所示: $this->Client->find('all',['recursive' => -1]) 返回 array( (int) 0 => array( 'Client' => array( 'id' => '1', 'name' => 'Intel Corporation', 'website' => 'www.intel.com',
$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'
),
))
我想在native Cake中使用param调用或其他方法来实现这一点,但如果必须在php数组函数中实现这一点,请解释。它基本上是分页的数据。这就是Cake的工作方式 您确定需要移动内部阵列吗?你可以按原样使用它 无论如何,移动内部数组非常简单:
foreach ($clients as & $client) {
$client = $client['Client'];
}