grasperstail Posted November 29, 2007 Share Posted November 29, 2007 I am using an include file to store an array sueful to more that one script in my site. When I try checking the array in the include for a value it returns a 1 even though the key does not exist. How can I return a false when the key does't exist? [color="#0000FF"]include file<?php$build_list['56'] = "AE Building";$build_list['133'] = "Acid House";$build_list['2'] = "Agriculture Building";$build_list['50'] = "Albany Village";$build_list['3'] = "Alumni House";$build_list['48'] = "Animal Behavior Research";$build_list['79'] = "Bancroft Library";$build_list['353'] = "2195 Hearst";?>[/color]include 'buildingarray.php';$photo_file = "Photos/" . $build_list[$show_result['code']] ;if (file_exists($photo_file)){...process code} Link to comment Share on other sites More sharing options...
justsomeguy Posted November 29, 2007 Share Posted November 29, 2007 You can use the array_key_exists function to test if a key exists.http://www.php.net/manual/en/function.array-key-exists.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.