Jump to content

Recommended Posts

<?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.

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/
Share on other sites

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";
}
}

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818528
Share on other sites

<?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)

 

 

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818533
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/155541-if-work-in-database/#findComment-818689
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.