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)
);

```
```
<?php
  $txt = 'text das text dss text good text text bad text';
  $search = 'good text';

  $pos = -1;

  $i = 0;

  while (isset($txt{$i})) {
    $j = 0;

    $wrong = false;

    while (isset($search{$j})) {
      if ($search{$j} != $txt{$i + $j}) {
        $wrong = true;

        break;
      }

      $j++;
    }

    if (!$wrong) {
      $pos = $i;

      break;
    }

    $i++;
  }

  echo 'Position: '.$pos; // in your case it will return position: 23
?>

```