-1

我遇到了这种非常奇怪的情况。PHP如下:

$complete_categories_list=array();

foreach ($modules_library_processed as $key=>$modules_categories_rendered) {
    foreach ($modules_categories_rendered['modulecategories'] as $module_category_key=>$module_category_values) {
        foreach ((array) $module_category_values as $module_key_inner=>$module_category_value) {
            $complete_categories_list[]=trim($module_category_value);
        }
    }
}

这在 Unix/Linux localhost 中运行良好,在某些情况下可以在 Windows localhost 中运行。但不是全部。问题是在循环结束时,$complete_categories_list即使$modules_library_processed上面有一些数据,它也是空的。$modules_library_processed是一个非常大的数组,所以我不能在这里发布整个数据。我希望有人可以阐明这一点。

更新:源是 simplexml_load_string($modules_xml_exported);我转换为数组的 XML 文件。结果是$modules_library_processed

print_r($module_category_values)结果到 SimpleXMLElement Object()

但是我将它类型转换为一个数组..所以应该可以正常工作吗?

4

1 回答 1

0

我想我已经解决了问题根本原因是脚本处理 SimpleXML,当脚本在 Windows 下运行时,即使使用了所有类型转换等,它也不会播放。我最终重写了我的脚本,所以它不会输出任何 SimpleXML元素,但全部采用数组/字符串格式。我希望这可以帮助别人。谢谢。

于 2013-06-24T02:06:08.647 回答