2016-03-16 75 views
0

每你好這裏是ExtJS的數組創建於ExtJS的傳遞

data: [ 
     ['W1',"Avail Qtr Opty",76343,"In-Period Bookings",20031], 
     ['W2',"Avail Qtr Opty",178990,"In-Period Bookings",143459], 
     ['W3',"Avail Qtr Opty",275758,"In-Period Bookings",208139], 
     ['W4',"Avail Qtr Opty",464345,"In-Period Bookings",299032], 
     ['W5',"Avail Qtr Opty",580025,"In-Period Bookings",384006], 
     ['W6',"Avail Qtr Opty",734469,"In-Period Bookings",406092], 
     ['W7',"Avail Qtr Opty",857489,"In-Period Bookings",501320], 
     ['W8',"Avail Qtr Opty",969641,"In-Period Bookings",559783], 
     ['W9',"Avail Qtr Opty",1076497,"In-Period Bookings",559783], 
     ['W10',"Avail Qtr Opty",1173833,"In-Period Bookings",559783], 
     ['W11',"Avail Qtr Opty",1279387,"In-Period Bookings",559783], 
     ['W12',"Avail Qtr Opty",1412080,"In-Period Bookings",559783], 
     ['W13',"Avail Qtr Opty",1736327,"In-Period Bookings",559783] 
    ] 

我怎麼能生成一個以這種形式在PHP我的數據在陣列形式的格式?

感謝

+0

用'$ data =' – Daan

+0

替換'data:'我的意思是我如何在php中以上面的形式生成一個數組? – user2628788

+0

您是否試圖從一組數據中生成數據?或者你只是想在PHP中定義一個變量? –

回答

0

嘗試是這樣的:通過創建一個空數組$data

開始:

$data = []; 

然後創建一個數組($data_element)添加到$data數組:

$data_element = ['W1',"Avail Qtr Opty",76343,"In-Period Bookings",20031]; 

最後,通過以下兩種方法的推$data_element陣列到$data數組的末尾:

array_push($data, $data_element); 

$data[] = $data_element; 

建議[該array_push文檔中]於一次只向$data陣列添加一個元素時,請使用第二個選項。如果您想一次將多個陣列添加到$data,則應使用array_push()函數。要做更多的行,你可能需要某種for-loop或while循環。

相關問題