我有一个数组“$results”,其中包含使用正则表达式从网页中抓取的结果集。我在遍历数组以将数组的整个数据写入 .csv 文件时有点困惑。
这是按以下方式打印后的数组输出。
print_r ($results); //printing the array
输出
Array
(
[fullName] => Ogdensburg Walmart Store #2092
[street1] => 3000 Ford Street Ext
[city] => Ogdensburg
[state] => NY
[zipcode] => 13669
[phone] => (315) 394-8990
[latitude] => 44.7083
[longitude] => -75.4564
)
Array
(
[fullName] => Evans Mills Walmart Supercenter Store #5497
[street1] => 25737 Us Route #11
[city] => Evans Mills
[state] => NY
[zipcode] => 13637
[phone] => (315) 629-2124
[latitude] => 44.0369
[longitude] => -75.8455
)
Array
(
[fullName] => Watertown Walmart Supercenter Store #1871
[street1] => 20823 State Route 3
[city] => Watertown
[state] => NY
[zipcode] => 13601
[phone] => (315) 786-0145
[latitude] => 43.9773
[longitude] => -75.9579
)
我只使用过简单的数组,谁能给我提示如何遍历$results
数组以将其写入 .csv 文件或 .xls 文件。