String comparison in several parts
Posted: Sun Apr 04, 2004 11:17 pm
Hi,
How can you compare two strings to see if any part of the string matches even if it is separated by paces or extra characters etc. Sorry i can't really put into words what i need to do so I'll give an example.
Say you've got two variables:
strpos($variable1, $variable2); only finds the the position in the string if $variable2 is just "fox" but not those two words in the wrong order etc.
Am I getting somewhere near to explaining what i need to do here?
Basically, I want an
And if I was using those two variables I need it to /*Do Some thing*/.
Is there a string function which will do this or am I fighting a losing battel here?
Case insensitive would be great too!
Thanks
How can you compare two strings to see if any part of the string matches even if it is separated by paces or extra characters etc. Sorry i can't really put into words what i need to do so I'll give an example.
Say you've got two variables:
Code: Select all
<?php
$variable1 = "The quick brown fox jumped over the fence";
$variable2 = "jumped fox";
?>Am I getting somewhere near to explaining what i need to do here?
Basically, I want an
Code: Select all
<?php
if(/*some string function*/($variable1, $variable2) !== false) {
/*Do Some thing*/
} else {
/*Do other*/
}
?>Is there a string function which will do this or am I fighting a losing battel here?
Case insensitive would be great too!
Thanks