數組替換不能正常工作或者我錯過了一些東西。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