Jump to content

Match tables and areas


katerina

Recommended Posts

I need it in diferrent regular expressions one for table and another for area.

 

I try

<html>
<body>

<?php
  $url="http://www.microsoft.com";
  $file = file_get_contents($url);

  preg_match_all('%<table[^>]*>.*?</\1>%', $file, $matches);
  print_r($matches);
?>
</body>
</html>

 

But I take error : Warning: preg_match_all() [function.preg-match-all]: Compilation failed: reference to non-existent subpattern at offset 20 in C:\wamp\www\php examples\example.php on line 7

 

 

And last question, I have to do this for every element on a html code.

Is there an easier way ??

Something like

 

switch($elem)

{

case 'a' : . . .

case 'area' : ...

case 'table' : ...

case 'td' : ...

}

 

Thanks again

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.