You are here: Re: Code snippet for recursive file reading? « All PHP « IT news, forums, messages
Re: Code snippet for recursive file reading?

Posted by ZeldorBlat on 10/13/64 11:34

Curtis wrote:
> Any suggestions for a recursive algorithm that reads text
> file A line by line until it encounters a line directing to
> it read in a similar manner file B which might have command
> lines for reading files C and D, and so forth.
>
> It might look like so:
>
> A
> A
> A
> A
> A
> READ B
> B
> B
> READ C
> C
> C
> B
> B
> A
> A etc.
>
> The objective is to have one large array or string of text
> with the referenced files as includes. I think I can manage
> the recursive file opens, though I haven't tested code yet.
> Questions:
>
> Any limit to number of files? (Is file() the best function
> for this?)
>
> Best way to prevent circular references? (Place each
> filename in an array with its calling file as a key and...?)
>
> Guidance appreciated.
>
> --
>
> Curtis
>
> Visit We the Thinking
> www.wethethinking.com
> An online magazine/forum
> devoted to philosophical
> thought.

If you just want to include files, why go through all that trouble?
Just use include_once() instead of include(), then nest things
appropriately. For example:

In A.php, include_once("B.php");
In B.php, include_once("C.php");

Then, just include_once("A.php") and he will include B, which will in
turn include C. Using include_once() solves your circular problem,
since no file will ever be included more than once.

Of course I could be totally misunderstanding your problem, also.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация