数组替换不能正常工作或者我错过了一些东西。array_search()错误
我想,以取代“读了致命错误后,停在你的XML文件,但是当我用下面针对关键值的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
)
'var_dump($ key)'给你什么? – deceze 2012-07-30 10:14:45
您确定这是您使用的确切代码吗?因为它工作正常或我。 – 2012-07-30 10:19:47
bool(false)bool(false)bool(false)bool(false)bool(false)int(3) – BentCoder 2012-07-30 10:19:48