Re: grabbing variable from bottom to top
| From: | Justin French | Date: | Mon, 04 Aug 2003 03:20:59 +0000 |
| Subject: | Re: grabbing variable from bottom to top | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158113@lists.php.net to get a copy of this message | ||
Ok, this is completely off the top of my head, and there is more than likely a better way, but if you HAVE to do this, then I guess here's an option:
1. turn on ob (output buffering at the top of the script
2. where you want the counter to be, echo something unique like #!@counter#!@
3. once the script has ended flush the contents of OB into a variable like $obContents
4. do a str_replace('#!@counter#!@',$yourCounterValue, $obContents)
5. echo the $obContents to the screen
I think a smarter way would be to re-organise your code somehow so that it does what you want, but maybe that can't be done (no way to know without seeing the code).
Good luck,
Justin French
On Monday, August 4, 2003, at 01:04 PM, Micah Montoy wrote:
Anyone know of a way to use a variable that isn't defined until further down the script at the top. I have a counter and once everything runs through the script, the count is complete, I need to display this at the top above the displayed results. I thought about and tried a function but I still run into the same problem. thanks