[thelist] recursive PHP functions

DESCHAMPS Stéphane DvSI/SICoR stephane.deschamps at francetelecom.com
Mon Sep 16 11:34:01 CDT 2002

> -----Message d'origine-----
> De : thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org]De la part de Jay Blanchard

> I don't know that you can call the functions again from
> within the
> function. There are other ways to write this.


In this exact case, yes. But I understood it more like an way for Mircea to
understand the notion of recursive functions.

Mircea, here's one case where recursive functions are really useful:

Suppose you have categories and subcategories in a page, for instance a
bookmark list.
Suppose each category is either child of, say "0" (root), or of another

A useful recursive function in that case would query my data base on the
children of 'n' categories


function displayBookmarks($id) {

  query database and echo $name of $id if $id != 0
  else echo "parent"

  query database and find all records where id_parent == id
  -> indent
  -> displayBookmarks(each record's id)
  -> end indent




Is it what you were looking for, Mircea?

(if anybody's interested in the real code, email me at
notabene_at_members.evolt.org and I'll send it to you, unfortunately I'm in
the office and my code is at home).

s t e f

More information about the thelist mailing list