
Originally Posted by
Yearupie
U can try something like this?
PHP Code:
<?php
$string = "xxxlxxxoxxxvxxxexxx";
$result = (string)NULL;
$done = false;
$string = substr($string,3);
$split = str_split($string);
$result .= $split[0];
while(!$done) {
$string = substr($string,4);
$split = str_split($string);
$result .= $split[0];
if(empty($string))
$done = true;
}
echo $result;
?>
Let me rephrase this. So you set the number to 3 so that it would search the string at the skip of 3 letters.
What I'm looking for is that I want to search a $keyword like love within the string.
- My logic is that I have to break the string into an array of letters;
- break the $keyword into and array of letters
- create a for loop to search
- make the array of the count($keyword)*$i not exceed the count($string) else exit the loop
- here's where I find tricky: I need to match all the letters of the keyword to the letters of the string at the given equidistant letter sequence or $els which is a variable, or maybe use the $i from the for loop instead.
I have a question about the if statement:
can i bring in an array within the if brackets:
PHP Code:
if($kw[$k]==$str[$i] && $kw[$k]==$str[$i]...depending at the number of $key){
...}