By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,369 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,369 IT Pros & Developers. It's quick & easy.

Tree data structure

P: n/a
Hi there!

I'm facing an issue concerning tree data structure in php.
In others languages, I just need to create a root node which I bind
pointers of instances representing others nodes.
But I couldn't find a way to do so in php language. Indeed, object
instances are "volatile" reaching the end of the script. How could I
build a tree with "volatile" address pointers in php ?
I could use arrays to store data like a tree structure but I'd like to
find another way..

do you have any suggestions ?

thanks a lot :)

Jul 10 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a


On Jul 10, 4:31 pm, PaowZ <gpa...@gmail.comwrote:
I could use arrays to store data like a tree structure but I'd like to
find another way..

do you have any suggestions ?
A database is another way, but if you don't want to use arrays, I can
imagine that you certainly wouldn't want to use a database.

Jul 10 '07 #2

P: n/a
PaowZ wrote:
Hi there!

I'm facing an issue concerning tree data structure in php.
In others languages, I just need to create a root node which I bind
pointers of instances representing others nodes.
But I couldn't find a way to do so in php language. Indeed, object
instances are "volatile" reaching the end of the script. How could I
build a tree with "volatile" address pointers in php ?
I could use arrays to store data like a tree structure but I'd like to
find another way..

do you have any suggestions ?

thanks a lot :)
Well, can emulate a C/C++ structure with a class; I've created AVL trees
that way and it works well.

You don't use pointers in PHP; just clone the new node and place it in
the appropriate root.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 11 '07 #3

P: n/a
On 10 juil, 23:12, lawp...@gmail.com wrote:
On Jul 10, 4:31 pm, PaowZ <gpa...@gmail.comwrote:
I could use arrays to store data like a tree structure but I'd like to
find another way..
do you have any suggestions ?

A database is another way, but if you don't want to use arrays, I can
imagine that you certainly wouldn't want to use a database.
It depends... What do you mean by using database?

Jul 11 '07 #4

P: n/a
On 11 Jul, 11:19, PaowZ <gpa...@gmail.comwrote:
On 10 juil, 23:12, lawp...@gmail.com wrote:
On Jul 10, 4:31 pm, PaowZ <gpa...@gmail.comwrote:
I could use arrays to store data like a tree structure but I'd like to
find another way..
do you have any suggestions ?
A database is another way, but if you don't want to use arrays, I can
imagine that you certainly wouldn't want to use a database.

It depends... What do you mean by using database?
See:
http://www.sitepoint.com/article/hie...-data-database
and
http://dev.mysql.com/tech-resources/...ical-data.html
for discussions on how to do it.

Jul 11 '07 #5

P: n/a
On 11 juil, 12:54, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 11 Jul, 11:19, PaowZ <gpa...@gmail.comwrote:
On 10 juil, 23:12, lawp...@gmail.com wrote:
On Jul 10, 4:31 pm, PaowZ <gpa...@gmail.comwrote:
I could use arrays to store data like a tree structure but I'd like to
find another way..
do you have any suggestions ?
A database is another way, but if you don't want to use arrays, I can
imagine that you certainly wouldn't want to use a database.
It depends... What do you mean by using database?

See:http://www.sitepoint.com/article/hie...-data-database
andhttp://dev.mysql.com/tech-resources/articles/hierarchical-data.html
for discussions on how to do it.
thanks for the links.. really interesting since I got started thinking
this way :)

Jul 11 '07 #6

P: n/a
On 11 Jul, 13:12, PaowZ <gpa...@gmail.comwrote:
On 11 juil, 12:54, Captain Paralytic <paul_laut...@yahoo.comwrote:


On 11 Jul, 11:19, PaowZ <gpa...@gmail.comwrote:
On 10 juil, 23:12, lawp...@gmail.com wrote:
On Jul 10, 4:31 pm, PaowZ <gpa...@gmail.comwrote:
I could use arrays to store data like a tree structure but I'd like to
find another way..
do you have any suggestions ?
A database is another way, but if you don't want to use arrays, I can
imagine that you certainly wouldn't want to use a database.
It depends... What do you mean by using database?
See:http://www.sitepoint.com/article/hie...-data-database
andhttp://dev.mysql.com/tech-resources/articles/hierarchical-data.html
for discussions on how to do it.

thanks for the links.. really interesting since I got started thinking
this way :)- Hide quoted text -

- Show quoted text -
They are my bible on this subject!

Jul 11 '07 #7

P: n/a
On Jul 11, 6:19 am, PaowZ <gpa...@gmail.comwrote:
>
It depends... What do you mean by using database?
I was referring to a relational database.

You could use MySQL ( or Postgres if your webhost has it, or whatever
other relational database you can install if you administrate the
machine )

It would take more time to build the code to create the tree stucture
in the tables, but I imagine you could reference things in the
database tree pretty easily once it's set up -- probably much easier
than messing with a tree structure in a PHP array.

Jul 11 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.