如何在codeigniter中循环来自多维数组的数据

时间:2017-10-21 05:57:08

标签: php codeigniter

我发现在多维数组中循环数据存在问题。我收到了错误。我认为 undefined $ t 。 这是我的控制器:

textview.setText(sb.toString());
// or can collect list as string using loop and display it

和我的观点

$dp[] = array(
        'id'                => $ft->idpr_order,
        'nor_order_pro'     => $ft->no_order_pro,
        'product_name'      => $ft->nama_produk,
        'sku'               => $ft->artikel,
        'brand'             => $ft->merk,
        'discount'          => $discft,
        'size'              => $ukr,
        'color'             => $wrn,
        'qty'               => $ft->qty,
        'price_before'      => $hg_before,
        'price_fix'         => $ft->harga_fix,
        );
    }

    $exp = explode('|', $resex);    
    $data_cs = array(
        'inv'      => $invoice,
        'tglOrdercs' => date('d F Y H:i:s'),
        'tglExp'   => $date_maju,
        'nmlkp'    => $nmlkpi,
        'almtkp'   => $address,
        'note'     => $note_ol,
        'kota'     => $city,
        'prov'     => $prov,
        'layanan'  => $exp[0],
        'etd'      => $exp[1],
        'tarif'    => $exp[2],
        'noTelp'   => $notelp271,
        'methode'  => $method,
        'bnk_option' => $banking_select,
        'cabang'   => $banking_inf_cab,
        'no_rek'   => $banking_inf_no,
        'an_bnk'   => $banking_inf_an,
        'subtotal' => $subt,
        'kode_pembayaran' => $code_unik,
        'total_belanja' => $tot_bel,
        'berat_total' => $tot_ber,
        'data_order' => $dp
     );
    $body = $this->load->view('em_info_notification_group/mail_order_for_admin',$data_cs,TRUE);

在我看来我得到了错误。我认为 undefined $ t 。实际上我要将数据解析为管理模板html。我已经做了各种各样的方法但没有任何作用

1 个答案:

答案 0 :(得分:0)

将循环结构更改为:

    foreach ($data_order as $data):
      if (is_array($data)):
        foreach ($data as $t):

此致