View Full Version : ensure that word exists in variable

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

03-22-2010, 12:28 PM

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
// Action if .com doesn't exist here

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum