Page 1 of 1
Search for a specific string !!
Posted: Tue Feb 05, 2008 6:03 am
by l_kris06
Hi all,
Can somebody here help me out with this please?
I have a string $temp = "word1 word2 word3 word4 word5 word6 word7....etc"
i need only "word2 word3 word4" to be in a variable, the count maybe more...basically
i need to set a start and end marker and get the string in between.
any help would be much appreciated.
Thanks,
kris
Re: Search for a specific string !!
Posted: Tue Feb 05, 2008 7:19 am
by webspider
Code: Select all
$temp = "word1 word2 word3 word4 word5 word6 word7";
$findWord = "word2";
$pos = strpos($temp, $findWord);
echo substr($temp, $pos); // or store in variable
Re: Search for a specific string !!
Posted: Tue Feb 05, 2008 7:55 am
by webspider
i need to set a start and end marker and get the string in between.
Code: Select all
$startPosition = strpos($temp, "word2");
$endPosition = strpos($temp, "word4");
$newString = substr($temp,$startPosition, $endPosition); //get the string
Re: Search for a specific string !!
Posted: Tue Feb 05, 2008 11:16 am
by RobertGonzalez