0
$this->layout='defaultall';

    $id = $this->Auth->user('idUser');
    $data= $this->Contact->find('all',array(
        'conditions' => array('Contact.User_id' => $id)));
          $this->set('contacts',$data);


 $this->loadModel('Calllog');

  /*  for($i=1; $i < 2; $i++)
    {
        $mobile =$data[$i]['Contact']["mobileNo"];
        $work =$data[$i]['Contact']["workNo"];
        $home =$data[$i]['Contact']["homeNo"];*/



   for($data as $datas){

      $mobile=  $datas['Contact']['mobileNo'];
      $home=  $datas['Contact']['homeNo'];
      $work=  $datas['Contact']['workNo'];




      $recent=$this->Calllog->find('all',
          array('order'=>'Calllog.idCallLog DESC',
              'limit' => 1,
              'conditions' => array('Calllog.mobileNo' => array($mobile,$work,$home ),
                  'Calllog.User_id' => $id


              )));

      //here array want to declare


      $this->set('a',$recent);

//在这里我想声明一个保存每次迭代数据的另一个数组..因为我不想覆盖数据

抱歉,我在数组中待了一个星期……请告诉我如何打印数组……如果我想在我的视图页面中显示第一次迭代结果

4

1 回答 1

1

如果您只想向数组添加新元素而不删除其内容,您可以这样做:

$recent[] = 'new_string1';

或者如果您有更多元素:

array_push($recent, 'new_string1', 'new_string2');

但在未来,请阅读手册: http: //php.net/manual/en/function.array-push.php

于 2013-06-19T09:27:20.463 回答