Re: Populate var with function output string?

From: Date: Tue, 04 Mar 2003 01:38:49 +0000
Subject: Re: Populate var with function output string?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-138011@lists.php.net to get a copy of this message
At 04:56 04.03.2003, CF High said: --------------------[snip]-------------------- >Hey all. > >Is it possible to populate a var with an output string generated by a >function? So: > >******************************* >function write_string(count) { > > for ($x = 0; $x < $count; $x++) { > > echo "<option value=$x> Row $x</option>"; > > } > >} > >$my_string = write_string(5); > >echo $my_string; >******************************* > >I need $count option elements stored in $my_string. How to make this happen. --------------------[snip]-------------------- You might use output buffering: ob_start; write_string(5); $my_string = ob_get_buffer(); ob_end_clean(); Output buffering is stackable, i.e. the above code will work even if you have ob turned on already. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#138011) next »