How To Find In String Finding Value In String With PHP
Post Description:
Post Tags: how, to, find, in, string, finding, value, in, string, with, php
This Post Has Been Viewed 388 Times Since Mon Mar 03, 2008 8:34 pm Posted By
hostman with 2 replies
Next Post »»
php function remove domain name get tld splitter split
strpos()
you can use this function to find a word or letter or number in a string, it its found, it will retrun true.
more info at
http://php.net/manual/en/function.strstr.php
example, lets say i want to know if $string has any words wallpaperama in it
$string = 'wallpaperama has cool and amazing wallpapers';
$find = 'wallpaperama';
if(strpos($string, $find ){
echo 'yes, its found'
}else{
echo 'not found';
}
Comments and replies About How To Find In String Finding Value In String With PHP
you are referring to php.net with the function strstr and you are mentioning the function strpos. this peace of code works only when you are using the strstr function. the code you are giving now, and the strpos() you have in your post title are wrong.
[code]
if(strstr($ $find)
{
echo 'yes, it\'s found';
}
else
{
echo 'sorry, this entry isn\'t found';
}
[/code]