RE: [PHP-DB] check string contens

From: Date: Tue, 27 Jun 2000 16:01:55 +0000
Subject: RE: [PHP-DB] check string contens
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-667@lists.php.net to get a copy of this message
> What am i dooing wrong. I want to check for the string http:// > in a > datafield and if it is there do nothing and if it is not there add it. > > $mask="http://"; > $test=strtolower(trim(substr($webpage,0,7))); > $binchk=strcmp($webpage,$mask); > if ($binchk<=1){ > $webpage=$mask.$webpage; > } Your example doesn't have any use for the $test variable...why do you use it? Would this not be simpler? /* Untested */ $mask="http://"; if (!stristr($webpage, $mask)) { $webpage = $mask . $webpage; } Sincerely, Craig Vincent

« previous php.db (#667) next »