String comparison; finding "how" characters

I am doing a quick recheck of the form. When comparing two lines, I tried something like this:

if (stripos($_SESSION['website'], $f['website']))

I get this error:

Fatal error: Call to undefined function: stripos() in...

I do not want this to be an exact match, mainly if $_SESSION['website']- www.google.com, I would like it to striposreturn trueif $f['website]- www.goog.com

Am I doing something wrong, or is there a better way to do this?

edit: I did some testing and noticed that my variable $_SESSION['website']contains wwwand .com. Like my variable $f['website]. shouldn't strposreturn this value as true?

+3
source share
2 answers

stripos(), PHP 5 . stripos , , PHP 4, . . - , strpos, :

<?php
// PHP 5.
$pos = stripos( 'www.google.com', 'google.com' );

// PHP 4.
$pos = strpos( strtolower( 'www.google.com' ), strtolower( 'google.com' ) );

, - : if( stripos( $foo, $bar ) ), 0, $foo $bar. if( stripos( $foo, $bar ) !== false ).

: , . www.google.com www.goog.com, . , stripos , " ".

"", ,

+5

strpos ('Your String Websitename', 'Term Search');

, true, false

$a=strpos($_SESSION['website'], $f['website'])

($ == TRUE)  {

    //do stuff

}     {

    //other stuff
}
-2

All Articles