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? Quote 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); Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/72661-in_array-question/#findComment-366350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.