Array
(
    [0] => Array
        (
            [tourid] => 31
            [sortid] => 27
            [tour_title] => 北欧4国+峡湾10日
            [0] => Array
                (
                    [0] => Array
                        (
                            [tour_price_id] => 1
                            [tour_id] => 31
                            [start_time] => 07月5、12、18日
                            [stard_price] => 0
                            [more_price] => 18200
                            [most_price] => 0
                            [airline] => AY(芬兰航空)
                        )                    [1] => Array
                        (
                            [tour_price_id] => 2
                            [tour_id] => 31
                            [start_time] => 08月5、9、12、20日
                            [stard_price] => 0
                            [more_price] => 18200
                            [most_price] => 0
                            [airline] => AY(芬兰航空)
                        )                )        )    [1] => Array
        (
            [tourid] => 30
            [sortid] => 27
            [tour_title] => 北欧4国+峡湾10日
            [0] => Array
                (
                )        ))这个是从数据库中读取出来的数据,我给存放到数组中,请问如何在模板文件中显示出来呢,关键是里边数组下标为0的那一层!!!

解决方案 »

  1.   

    $smarty->assgin("data",$data);
    $data.0.tour_title
    $data.0.0.0.start_time
    $data.0.0.1.start_time
    $data.1.tour_title
      

  2.   

    给你个例子看下程序代码$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
      array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));html今天静态页面
    {section name=sec1 loop=$contacts}
    phone: {$contacts[sec1].phone}<br>
    fax: {$contacts[sec1].fax}<br>
    cell: {$contacts[sec1].cell}<br>
    {/section}
      

  3.   

    很简单的,在模版中用循环就OK了  
    例如://=====在PHP中=====
         $smarty->assign("Array",$Array);
      $smarty->display("模版名");    
    //=====模版=====
      {section name=n loop=$Array}   
      {$Array[n].start_time} //就可以显示出时间了
      {/section}加QQ群吧: 108436639   108436639
      

  4.   

    你应该用 smarty 提供的赋值方法 assign 对模板变量赋值,而不是自己组装数组