How To Find In String Finding Value In String With PHP



How To Find In String Finding Value In String With PHP
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
How To Find In String Finding Value In String With PHP

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';
}

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Find In String Finding Value In String With PHP




:: 1 :: #44700 - Reply By hostman On Sat Mar 08, 2008 10:28 am
:: 2 :: #62813 - Reply By Dempsey On Tue Jul 22, 2008 2:21 am
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]