By the look of the code on this thread and the other one we were talking on, I'm guessing you come from a C programming background. You can use a lot of C style techniques in PHP (without the need for all that nasty malloc'ing!), but PHP provides a lot of much easier ways round a lot of common tasks.
Tefra already pointed out using 'explode' to chunk up a string into an array. You might also want to look at some of the other array functions, like array_pop.
As an example, a common requirement is to separate a filename from a directory path. Instead of doing it the C way with a tail recursive function doing substr's by steam, you would do it something like this:
Code:
$dir = '/some/path/to/a/file.txt';
$path_array = explode('/',$dir);
$file = array_pop($path_array);
$path = implode('/',$path_array);
... so $file now contains 'file.txt' and $path is '/some/path/to/a'.
You might want to consider recoding the stuff you posted on that other thread using arrays rather than doing string manipulation, if nothing else as an exercize in getting used to The Tao of PHP. PHP makes that kind of tokenizing and stack processing soooo easy ... I actually break out in hives whenever I have to actually do any serious C/C++ coding these days.
And just in case you didn't know, getting function descriptions is as easy as ...
http://www.php.net/array_pop
... or whatever function you need.
-- hugh