Jump to content

if statement contains value...


Collegeboox

Recommended Posts

Can someone write me some simple code to check to see if the url has the word "soundcloud" in them. This is what I want to do....

 

This is my code now...

	 echo "
	           <h3>      $title - $author</h3>
	            </br>
				<iframe width='640' height='360' src='$link' frameborder='0' allowfullscreen></iframe>
				</br>
				</br>
				$message
				</br>
				<font color='#8b8d9b' size='1'>Posted By: $username $date</font>
				</br></br></br></br></br>
	      ";

 

However I want to pull the link value out of the database and see if it contains the word "soundcloud" and if it does do this...(note the height is changed)

	 echo "
	           <h3>      $title - $author</h3>
	            </br>
				<iframe width='640' height='100' src='$link' frameborder='0' allowfullscreen></iframe>
				</br>
				</br>
				$message
				</br>
				<font color='#8b8d9b' size='1'>Posted By: $username $date</font>
				</br></br></br></br></br>
	      ";

 

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

strpos() returns the index of the starting position of the found string. That is to say, it returns the position of the first letter of the found string, or FALSE if the string is not found. However, indexes start at zero, so if the string is found at the very start, it will return zero, and zero is equivalent to false. So you have to do a test to make sure it's a boolean false, and not a zero false. This is done using the three equals signs: ===, or if you want to test to make sure it's not the boolean false, you use an exclamation with two equals signs: !==

 

And yes, what you wrote is correct.

Link to comment
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.