We Must Design Posted October 10, 2007 Share Posted October 10, 2007 I am wanting to check if a value is in array. I am using the following: $in_array = in_array ($name, $_SESSION['favoriteArray']); A problem occurs though when there is no data in the array. I get the error message: Warning: in_array() [function.in-array]: Wrong datatype for second argument How would I tell the script to only use the in_array function if there is a function to check? Link to comment https://forums.phpfreaks.com/topic/72661-in_array-question/ Share on other sites More sharing options...
darkfreaks Posted October 10, 2007 Share Posted October 10, 2007 in_array("favorite",$variable); Link to comment https://forums.phpfreaks.com/topic/72661-in_array-question/#findComment-366347 Share on other sites More sharing options...
Orio Posted October 10, 2007 Share Posted October 10, 2007 <?php if(is_array($_SESSION['favoriteArray'])) $in_array = in_array ($name, $_SESSION['favoriteArray']); else $in_array = FALSE; //Or whatever you think it should be... ?> Orio. Link to comment https://forums.phpfreaks.com/topic/72661-in_array-question/#findComment-366350 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.