PHP matching string

We can match string in PHP using strrpos function here is the sample code

<?php
function Match($keyword,$subject){
	if(strrpos($subject,$keyword)===false){
		return false;
	}else{
		return true;
	}
}

$keyword = 'insicdesigns.com';
$subject = 'I love insicdesigns.com';

if(Match($keyword,$subject)){
	echo 'Match!';
}else{
	echo 'Not found';
}

?>

It will display…

function Match($keyword,$subject){
if(strrpos($subject,$keyword)===false){
return false;
}else{
return true;
}
}

$keyword = 'insicdesigns.com';
$subject = 'I love insicdesigns.com';

if(Match($keyword,$subject)){
echo '

‘;
echo ‘Match!’;
echo ‘

‘;
}else{
echo ‘

‘;
echo ‘Not found’;
echo ‘

‘;
}
?>

PG

Author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.

Related Post

Delicious

2 Responses to “PHP matching string”

  1. Again this code is very usefull. I have used this code in VECO Website. :)

  2. function Match($keyword,$subject) {
    return strrpos($subject,$keyword)===false;
    }

    Better this way ;)

Leave a Reply