Classes & 2 Dim Array Help

This is a discussion on Classes & 2 Dim Array Help within the PHP General forums, part of the PHP Programming Forums category; I need to do some screen scraping and I am playing with a table object. I would like to iterate ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-10-2004
 
Posts: n/a
Default Classes & 2 Dim Array Help


I need to do some screen scraping and I am playing with a table object.
I would like to iterate through a table in the syntax of $table->tr->td or
$table->tr[$i]->td[$j] I Guess.

The problem is initializing my $td array.
I seem to get erroneous initialization values.

How do I do this simple test properly ?
Can I skip the $td declaration ?
Something seems wrong about that.

Thanks in advance.

#### table object ####

<?
Class Table {

var $tr = array("td" => array());

function testFill() {
$this->tr[0]->td[0] = "col1";
$this->tr[0]->td[1] = "col2";
$this->tr[1]->td[0] = "val1";
$this->tr[1]->td[1] = "val2";
}

function Table () {
$this->testFill();
}

}
?>

#### program ####

<?
include ("class.Table.php");

$table = new Table();

while (list($key,$row) = each($table->tr)) {
echo "$key = " . $row->td[0] . "\n";
echo "$key = " . $row->td[1] . "\n";
}
?>

#### erroneous output #########

td =
td =
0 = col1
0 = col2
1 = val1
1 = val2




Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:41 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0