Cooper94 Posted April 24, 2009 Share Posted April 24, 2009 <?php <?php foreach($clientlist as $client) { if((!strstr($client['29'] , "Naples Flying Club"))){ echo 'online'; }else{} } ?> I am trying to have it as if client['29'] has the words naples flying club in his comments it will show online! I thought the code strstr search's if the word is in that area. Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/ Share on other sites More sharing options...
jonsjava Posted April 24, 2009 Share Posted April 24, 2009 if it's a multi-dimensional array, use the 2nd one, otherwise, use the first: <?php foreach ($clientlist as $client){ if (stristr($client, "naples flying club")){ echo "online"; } else{ echo "offline"; } } /* or this will do it....hopefully */ foreach ($clientlist as $client){ if (stristr($client[29], "naples flying club")){ echo "online"; } else{ echo "offline"; } } Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818528 Share on other sites More sharing options...
mikesta707 Posted April 24, 2009 Share Posted April 24, 2009 <?php <?php foreach($clientlist as $client) { if((!strstr($client['29'] , "Naples Flying Club"))){ echo 'online'; }else{} } ?> I am trying to have it as if client['29'] has the words naples flying club in his comments it will show online! I thought the code strstr search's if the word is in that area. unless your clientlist array is multidimensional, the client variable wont be an array, (when you loop through an array with foreach, the variable after the "as" is a a variable equal to the current entry of the array you are accessing) Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818533 Share on other sites More sharing options...
jonsjava Posted April 24, 2009 Share Posted April 24, 2009 said better than I said it, Mikesta. What he said *yawn...* Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818536 Share on other sites More sharing options...
Cooper94 Posted April 24, 2009 Author Share Posted April 24, 2009 Thank you guys so much and one more thing. On the code strstr function is there a way to make it delete content from up to down? So say I have hello world I want it to go down and just result hello. I know that it only goes up so all I know it would do is say world. Thank You Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818689 Share on other sites More sharing options...
Cooper94 Posted April 25, 2009 Author Share Posted April 25, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818736 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.