dk4210 Posted July 28, 2011 Share Posted July 28, 2011 Hello Guys, I have the following code foreach($ct->data as $key => $value){ if(!in_array($ct->data[$key][3],$arr_read_messages)){ $ct->data[$key][3]='<a class="ezjax" href="view_message.php?id='.$ct->data[$key][0].'" class=”unread”>'.$ct->data[$key][3].'</a>'; }else{ $ct->data[$key][3]='<a class="ezjax" href="view_message.php?id='.$ct->data[$key][0].'">'.$ct->data[$key][3].'</a>'; } and when I run the code I get the error message Warning: in_array() [function.in-array]: Wrong datatype for second argument in Any idea what the error message means? Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/ Share on other sites More sharing options...
Muddy_Funster Posted July 28, 2011 Share Posted July 28, 2011 sounds like $arr_read_messages isn't formated as PHP would expect it to be, you could try if(!in_array($ct->data[$key][3], "$arr_read_messages")){ Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248432 Share on other sites More sharing options...
trq Posted July 28, 2011 Share Posted July 28, 2011 sounds like $arr_read_messages isn't formated as PHP would expect it to be, you could try if(!in_array($ct->data[$key][3], "$arr_read_messages")){ Variables do not need to be surrounded by quotes. The error means that $arr_read_messages is not an array. Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248434 Share on other sites More sharing options...
dk4210 Posted July 28, 2011 Author Share Posted July 28, 2011 What code could I add to tell that what is in the array? Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248444 Share on other sites More sharing options...
trq Posted July 28, 2011 Share Posted July 28, 2011 What? Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248449 Share on other sites More sharing options...
dk4210 Posted July 28, 2011 Author Share Posted July 28, 2011 Nevermind! Thanks guys for your help! Quote Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248454 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.