PHP Classes

Multi-Extract problem

Recommend this page to a friend!

      table2arr  >  All threads  >  Multi-Extract problem  >  (Un) Subscribe thread alerts  
Subject:Multi-Extract problem
Summary:Solved problem to multi-extract alot of content in one step
Messages:3
Author:Daniel Sepeur
Date:2006-04-27 09:45:12
Update:2006-04-28 11:42:12
 

  1. Multi-Extract problem   Reply   Report abuse  
Picture of Daniel Sepeur 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

  2. Re: Multi-Extract problem   Reply   Report abuse  
Picture of Wojtek Jarzecki Wojtek Jarzecki - 2006-04-28 11:28:50 - In reply to message 1 from Daniel Sepeur
I thank for finding mistake. It was guilty my habit to programming in Pascal Delphi. I used internal function.

Wojtek Jarzecki

  3. Re: Multi-Extract problem   Reply   Report abuse  
Picture of Daniel Sepeur Daniel Sepeur - 2006-04-28 11:42:12 - In reply to message 2 from Wojtek Jarzecki
No Problem.
It was a pleasure for me to help to make your program better working.
I think, if someone is using other peoples programs, the can also do something for that :-)

Daniel