...

View Full Version : ensure that word exists in variable



john_zakaria
03-22-2010, 12:01 PM
Hello everybody..

i select website addresses from database all that i need is ensure that is '.com' exists in variable or not

for example:
if $x[1]='www.yahoo.com' --> return true.

but if $x[1]='www.yahoo' --> return false with error message website is not entered correctly.

thanks in advance

JAY6390
03-22-2010, 12:28 PM
Use:
http://www.php.net/strstr

Search for .com in the string and it will return false if it isn't in the string

if(strstr($x[1], '.com') !== false) {
// Action if .com exists here
}else{
// Action if .com doesn't exist here
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum