-1
<?php
$tagname = "tr";    
$doc = file_get_contents("test.html"); 
$pattern = "/<$tagname>(.*?)<\/$tagname>/";
preg_match_all($pattern, $doc, $matches);
foreach ($matches as $match) {
    echo ++$xx; //counts up every match
    echo " -- ";
    echo $match;
    echo "\n\r";
}
?>

This puts the text in between into $match and prints it on the screen but only grabs the first occurrence and prints it 2 times on the screen it has about 20+ time the appears.

How can I make it put them all on the screen each on a new line?

kguest
  • 3,804
  • 3
  • 29
  • 31

1 Answers1

0

Change:

foreach ($matches as $match) {

To:

foreach ($matches[1] as $match) {
Misunderstood
  • 5,534
  • 1
  • 18
  • 25