Originally posted by kamurj
now how can i have the output stored in a variable so i can cache it istead of directly echoing it to the browser.
thank you in advance.
before telling you about output buffering (you can learn this later):
replace every " echo " with " $foo .= " .
in the first line you initialize $foo: by $foo = "";
and in the last line you put out $foo by " echo $foo; " .
should work.