-1

Is there a way to use the found occurrence within pattern? i.e.

$string='number23 cat99 dog23 car66';

for example, i want to find words that has number 23.... this doesnt work:

preg_match('/number(\d{2}) (.*?)%1/si', $string,  $new);
T.Todua
  • 53,146
  • 19
  • 236
  • 237

1 Answers1

0

Not sure I well understand your need, but how about using preg_match_all:

preg_match_all('/([a-z]+23)\b/i', $string, $matches);

This will match number23 and dog23

Toto
  • 89,455
  • 62
  • 89
  • 125