2016-04-12 15 views
1

に変換cakephp.Thisに変換するテーブルからデータを取得するための私のコードです。配列は、私は、文字列に配列を変換したいこんにちは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コードhere- 、私は完全に配列

(
    [0] => Array 
     (
      [Temptrip] => Array 
       (
        [search] => High Commission of Iran, Road No 75, Dhaka 
       ) 

     ) 

として配列としての私の出力を行っているが、私は私の出力と同じままのイランの[0] =>高等弁務官にしたいです道はありません75、ダッカ

答えて

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

関連する問題