希望大家都做的很好...拆分數組,使用隔板塊
我正在尋找類似array_chunk()
的東西,但使用空值作爲分隔符?
我有 -
Array
(
[0] => /some/path:
[1] => file.csv
[2] => file.dat
[3] =>
[4] => /some/other/path:
[5] => file.csv
[6] => file.csv.gz
[7] => file.dat
[8] =>
[9] => /some/other/other/path:
[10] => file.csv
[11] => file.dat
)
,並希望實現 -
Array
(
[0] => Array
(
[0] => /some/path:
[1] => file.csv
[2] => file.dat
)
[1] => Array
(
[0] => /some/other/path:
[1] => file.csv
[2] => file.csv.gz
[3] => file.dat
)
[2] => Array
(
[0] => /some/other/other/path:
[1] => file.csv
[2] => file.dat
)
)
現在我不能對每3只塊,你可以看到一些地方將有超過1個文件。
我可以通過循環和計數器實現,但我覺得會有一個更清潔的方法?
感謝
凡你從這個數組中獲取?也許有比這更好的解決方案。 –
@Jack它來自ftp_nlist('/ some/path/*'),它以上述格式返回數組。 – mybigman