数组到cakephp中的字符串转换

时间:2016-04-12 12:33:43

标签: php mysql arrays cakephp

您好我想将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号,

1 个答案:

答案 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);

来源:Hash::extract