可能重複:
how to skip elements in foreach loop的foreach輸出兩個陣列跳過第一
我有以下的foreach:
foreach($documents as $document):
print_r($document);
endforeach;
哪個輸出以下:
Array
(
[num] => 2
)
Array
(
[0] => Array
(
[name] => Batman
[url] => http://batman.com
)
[1] => Array
(
[name] => Superman
[url] => http://superman.com
)
)
第一個數組conatining [num] => 2,打印結果時我不想在我的foreach中使用。
但是,我如何擺脫該數組,所以它不會打印時,我使用寫print_r($文檔)?
感謝所有的答案。這最符合我的目的。 – JohnSmith