blacksmoke26 Posted November 14, 2009 Share Posted November 14, 2009 I have problem in my code: $edb = array ("s" => "File {NAME} does not exist."); if (!in_array("s", $edb)) { echo ('Error: 10: Number ' . 's' . ' not found in error list.'); } Output: Error: 10: Number s not found in error list. can anyone tell me where is an error? :'( Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/ Share on other sites More sharing options...
ram4nd Posted November 14, 2009 Share Posted November 14, 2009 Yes and what should it be? Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957563 Share on other sites More sharing options...
blacksmoke26 Posted November 14, 2009 Author Share Posted November 14, 2009 Element 's' is exist in $edb array! then why am getting message .... Element not found Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957566 Share on other sites More sharing options...
ram4nd Posted November 14, 2009 Share Posted November 14, 2009 use print_r on $edb Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957569 Share on other sites More sharing options...
Alex Posted November 14, 2009 Share Posted November 14, 2009 in_array() checks the values of an array, not the keys. Instead use array_key_exists() Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957570 Share on other sites More sharing options...
blacksmoke26 Posted November 14, 2009 Author Share Posted November 14, 2009 Oh yes... i upgraded my PHP to 5.3.0 from PHP 5.2.9. but this was working in PHP 5.2.9. Thanks AlexWD , your the rock... Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957573 Share on other sites More sharing options...
mrMarcus Posted November 14, 2009 Share Posted November 14, 2009 Oh yes... i upgraded my PHP to 5.3.0 from PHP 5.2.9. but this was working in PHP 5.2.9. Thanks AlexWD , your the rock... just tested in 5.2.9-1 and it doesn't work. Link to comment https://forums.phpfreaks.com/topic/181533-in_array-error/#findComment-957631 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.