RE: [PHP4BETA] Linked lists and binary trees
[email protected] ("Philip Murray")
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <[email protected]> |
Hi,
You can implement them using class's and the '&' operator.
See the Variables section in the manual for an explaination of '&'.
Example:
<?php
class LinkedList {
var $link;
var $name;
}
$foobarOne = new LinkedList;
$foobarOne->link = NULL;
$foobarOne->name = "Foobar One";
$foobarTwo = new LinkedList;
$foobarTwo->link = &$foobarOne;
$foobarTwo->name = "Foobar Two";
echo $foobarTwo->link->name;
?>
Should output "Foobar One"
If there's a better way, please enlighten me. :)
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Philip Murray
[email protected] [email protected]
"To understand recursion, first we must understand
recursion"
-- Anon