MemphiS Posted June 1, 2007 Share Posted June 1, 2007 I keep getting the following error: Warning: in_array() [function.in-array]: Wrong datatype for second argument in Code example: $post1 = $_POST['number1']; $post2 = $_POST['number2']; $post3 = $_POST['number3']; $array1 = array("1","2","3"); $array2 = array("$post1","$post2","$post3"); $array3 = array("1","2","3","$post1","$post2","$post3"); if (in_array("1", $array2)){ print("1 has been found."); } if (in_array("1", $array3)>2){ print("1 has been found twice in array 3."); } Once the POST values have been set its fine... and when not set they have no value and dispplays the above error... is there a solution to overcome this problem? Quote Link to comment https://forums.phpfreaks.com/topic/53845-solved-in_array/ Share on other sites More sharing options...
chigley Posted June 1, 2007 Share Posted June 1, 2007 Whats )>2 for when declaring the array haystack in the second if statement? Quote Link to comment https://forums.phpfreaks.com/topic/53845-solved-in_array/#findComment-266172 Share on other sites More sharing options...
MemphiS Posted June 1, 2007 Author Share Posted June 1, 2007 For if the number "2" is in the array more then once Quote Link to comment https://forums.phpfreaks.com/topic/53845-solved-in_array/#findComment-266176 Share on other sites More sharing options...
MemphiS Posted June 1, 2007 Author Share Posted June 1, 2007 The problem is that none of the array values in $post1 etc have been set so the array would look like $array2 = array("","","",""); untill i submit my $_POST data... not to sure how to fix this problem Quote Link to comment https://forums.phpfreaks.com/topic/53845-solved-in_array/#findComment-266179 Share on other sites More sharing options...
MemphiS Posted June 1, 2007 Author Share Posted June 1, 2007 hehe Nevermind i thought up a solution Quote Link to comment https://forums.phpfreaks.com/topic/53845-solved-in_array/#findComment-266186 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.