
 Daniel Sepeur - 2006-04-27 09:45:12
 
Hi,
I tried to extract alot of tables from different sites in one step.
Therefore i CURL all desired sites and give each content in array elements.
Now i need only a for-construct to extract the tables for all array elements in one step.
Here is an example:
<?php
  
  error_reporting(E_ALL);
  // Requesting table2arr.php
  require_once("table2arr.php");
  // Now do for all content elements in $content
  // a table extract
  for($i=0;$i<=count($content)-1;$i++) {
    $g=new table2arr($content[$i]);
    and so on....
  }
?>
In this case, i goet everytime the following error:
FATAL ERROR: Cannot redeclare findfirst() previously declared....
You know about this error. Its not nice.
This error occours, because the function "findfirst" is nested in the function "parsetable".
Therefore i redesigned the code of table2arr.php like this:
Copy the function "findfirst" like this:
function findfirst($table,$level) {
  foreach ($table as $key=>$arr) {
  	$flevel=$arr["level"];
        $flen=$arr["len"];
      	if (($flevel==$level) AND ($flen==0)) { return $key; }
  }
  return -1;
}
and place it directly after the last closing bracket of function "parsetable".
Then change
   $findidx=findfirst($this->table,$level);
in function "parsetable" to
   $findidx=$this->findfirst($this->table,$level);
After you made this changes, you are able to do multiple table extracts in one time.
Daniel