你好,我想在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]=>伊朗高级委员会,达卡75号公路

最佳答案

你可以这样试试。

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

10-04 17:12