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? 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")){ 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. 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? 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? 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! Link to comment https://forums.phpfreaks.com/topic/243088-troubleshooting-in_array-question/#findComment-1248454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.