本文介紹了Foreach 用于數組內的數組的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有一個數組,我對它做了一個print_r,它返回了這個......
I have an array and i did a print_r of it and it returned this...
Array ( [0] => Array ( [invoiceid] => 2 [client] => Test 1 [invoicedeliverymethod] => email [paymenttimeallotment] => 15 [clientid] => 1 [date] => 2012-04-12 [enddate] => 2012-04-02 00:00:00 [total] => 250.86 [remainingbalance] => 250.86 [ispaid] => No [isagentpaid] => No [datedistributed] => Not distributed [invoicedcontact] => 1 ) [1] => Array ( [invoiceid] => 1 [client] => Test 1 [invoicedeliverymethod] => email [paymenttimeallotment] => 15 [clientid] => 1 [date] => 2012-04-12 [enddate] => 2012-03-31 23:59:59 [total] => 602.29 [remainingbalance] => 602.29 [ispaid] => No [isagentpaid] => No [datedistributed] => 2012-04-12 [invoicedcontact] => 1 ) )
我嘗試運行此代碼...
I tried to run this code...
foreach($resultArray as $row => $value){
echo $value . "<br/>";
}
然后返回數組數組.
如何獲取這些數組中的值?
How do I get the values inside of these arrays?
推薦答案
你需要從數組內部迭代元素,像這樣:
You need to iterate the elements from the inside array, like this:
foreach($resultArray as $row => $innerArray){
foreach($innerArray as $innerRow => $value){
echo $value . "<br/>";
}
}
這篇關于Foreach 用于數組內的數組的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!