print_r($element_attrs);
返回从 xml 文件中收集的以下数组。
Array ( [WEATHER-SUMMARY] => Thunderstorms )
Array ( [WEATHER-SUMMARY] => Thunderstorms Likely )
Array ( [WEATHER-SUMMARY] => Chance Thunderstorms )
Array ( [WEATHER-SUMMARY] => Mostly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Mostly Clear )
Array ( [WEATHER-SUMMARY] => Sunny )
Array ( [WEATHER-SUMMARY] => Mostly Clear )
Array ( [WEATHER-SUMMARY] => Sunny )
Array ( [WEATHER-SUMMARY] => Partly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Partly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Rain Fog/Mist )
Array ( )
现在它们是 16 个独立的关联数组,其中所有的键都是相同的,除了最后一个由于某种原因是空白的。我想使用array_merge()
或另一个函数将这些单独的数组合并到一个大数组中,以便我可以返回倒数第二个值“雨雾/雾”
现在当我这样做时,print_r(array_merge($element_attrs));
我得到:
Array ( [WEATHER-SUMMARY] => Thunderstorms )
Array ( [WEATHER-SUMMARY] => Thunderstorms Likely )
Array ( [WEATHER-SUMMARY] => Chance Thunderstorms )
Array ( [WEATHER-SUMMARY] => Mostly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Mostly Clear )
Array ( [WEATHER-SUMMARY] => Sunny )
Array ( [WEATHER-SUMMARY] => Mostly Clear )
Array ( [WEATHER-SUMMARY] => Sunny )
Array ( [WEATHER-SUMMARY] => Partly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Partly Cloudy )
Array ( [WEATHER-SUMMARY] => Mostly Sunny )
Array ( [WEATHER-SUMMARY] => Rain Fog/Mist )
Array ( )