数组替换无法正常工作或我遗漏了一些东西。
我想将任何等于“读取时发生错误”的文本替换为“在 XML 文件中出现致命错误后读取已停止,但是当我使用低于键0的值的 PHP 代码时会更新,这是错误的!
任何的想法?
谢谢
原始状态:
Array
(
[0] => Element 'item', attribute 'isd': The attribute 'isd' is not allowed.
[1] => Element 'item', attribute 'avai0lable': The attribute 'avai0lable' is not allowed.
[2] => Unimplemented block at ..\xmlschemas.c:28274
[3] => An Error Occured while reading
)
PHP代码:
$errors = array_unique($errors);
$key = array_search('An Error Occured while reading', $errors);
$errors[$key] = 'Reading has stopped after fatal error in you XML file';
echo '<pre>'; print_r($errors); echo '</pre>';
错误结果:
Array
(
[0] => Reading has stopped after fatal error in you XML file
[1] => Element 'item', attribute 'avai0lable': The attribute 'avai0lable' is not allowed.
[2] => Unimplemented block at ..\xmlschemas.c:28274
[3] => Reading has stopped after fatal error in you XML file
)