News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

DevShed:
Fundamentals of Recursion in PHP (Part 1)
May 02, 2006 @ 07:31:46

DevShed has posted their latest tutorial today, a look at some of the basics of recursion and working with it in PHP.

Iteration is a straightforward concept. Recursion is a bit more complicated; it can be defined as a regular function that calls itself. PHP supports recursive functions. This article, the first of three parts, will explain recursive functions and help you see why they are useful.

Considering the important role that recursion plays in most programming languages, and specifically in PHP, over this series I'll be demonstrating how to define and use recursive functions with numerous code samples, thus you can learn quickly how to include them in your own PHP scripts.

If you've never used recursion, you're in luck - they start from the very beginning, explaining it with a simple example of pushing the entire contents of an array (with subarrays) out to a file. They use this exmaple as a base to improve the function, adding the function to write the data out. They finish it off with two handy recursive functions for everyday use - one to escape the entire contents of an array and one that does the same, but checks to see if magic quotes is on.

0 comments voice your opinion now!
tutorial fundamentals recursion basic example array tutorial fundamentals recursion basic example array


blog comments powered by Disqus

Similar Posts

TechTatva.com: [How To] Setup Cherokee with PHP5 FPM

Tom Jowitt's Blog: Streamlined PHP Development - Part II

Benjamin Eberlei's Blog: Using Zend_Soap Server and Autodiscover in a Controller

MrPHP.com.au: Image Cache using phpThumb and .htaccess

Josh Adell's Blog: GetSet Methods vs. Public Properties


Community Events





Don't see your event here?
Let us know!


opinion install configure introduction developer framework experience threedevsandamaybe interview wordpress list podcast community series testing laravel code language release unittest

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework