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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.