您好我想将cake数组转换为cakephp中的字符串转换。这是我从表中检索数据的代码。
$date_time_search=$this->Temptrip->find('all',array('fields'=>array('Temptrip.from_area as search'),'conditions'=>array('Temptrip.created >=' => $first1,'Temptrip.created <=' => $last2)));
$this->set('date_time_search', $date_time_search);
我的.ctp代码在这里 - 我已完成输出数组作为数组
(
[0] => Array
(
[Temptrip] => Array
(
[search] => High Commission of Iran, Road No 75, Dhaka
)
)
但我希望我的输出相同 - [0] =&gt;伊朗高级委员会,达卡路75号,
答案 0 :(得分:4)
你可以这样试试。
use Cake\Utility\Hash;
...
...
$date_time_search=$this->Temptrip->find('all',array('fields'=>array('Temptrip.from_area as search'),'conditions'=>array('Temptrip.created >=' => $first1,'Temptrip.created <=' => $last2)));
$results = Hash::extract($date_time_search, '{n}.Temptrip.search');
$this->set('date_time_search', $results);