-1

Trying to capture all text between tags.

Code:

$test = '<test>foo<tests> asdlkfjklas lkflsdakj <test>sdfsd<tests> asdlkaskl <test>235234<tests>';

$match = '/<test>(.*)<tests>/';

preg_match_all($match, $test, $nextLink);

Result of print_r:

Array ( [0] => Array ( [0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234 ) [1] => Array ( [0] => foo asdlkfjklas lkflsdakj sdfsd asdlkaskl 235234 ) ) 
Hunter S
  • 1,293
  • 1
  • 15
  • 26

1 Answers1

2

your regex syntax is greedy. use folowing:

 $match = '/<test>(.*?)<tests>/';
diavolic
  • 722
  • 1
  • 4
  • 5