Question: What i want to do is search for a text/words within a long text like:

```
$txt = 'text das text dss text good text text bad text';

```

and i want to search for `good text` in this `$txt` without using PHP functions like `stripos()` or others, i want to use just `for` in PHP and make minimum loops as possible.

How can i go through all the `$txt` searching for `good text` and getting what is after it?

Answer: 
```
<?php
function findRemaining($needle, $haystack) {
  $result = '';

  for ($i = 0, $found = false; isset($haystack[$i]); $i += 1) {
    if (!$found) {
      for ($j = 0; isset($haystack[$i + $j], $needle[$j]); $j += 1) {
        if ($haystack[$i + $j] !== $needle[$j]) {
          continue 2;
        }
      }

      $found = true;
    }

    $result .= $haystack[$i];
  }

  return $result;
}

$haystack = 'text das text dss text good text text bad text';
$needle = 'good text';

// string(23) "good text text bad text"
var_dump(
  findRemaining($needle, $haystack)
);

```
Try this one and let me know...

```
$txt = "text das text dss text good text text bad text";
function search_string($word, $text){
 $parts = explode(" ", $text);
 $result = array();
 $word = strtolower($word);

 foreach($parts as $v){

  if(strpos(strtolower($v), $word) !== false){
   $result[] = $v;
  }
 }
 if(!empty($result)){
    return implode(", ", $result);
 }else{
    return "Not Found";
 }
}
echo search_string("text", $txt);

```