swift1984m Posted June 15, 2008 Share Posted June 15, 2008 Hi, I am trying to add a plugin to an existing system (i cannot change anything in existing system), and i can use the function defined in exsiting system. now i write a program which uses this function from existing system. and this function echos some data as output. I want to have all the echoed data from the function in a string variable in my program. see the code snippet how right now i am calling the function $ps_product->show_snapshot. $ps_product->show_snapshot echos some data i want to store the echoed html to a variable $string. Please help me with this. $string="" foreach($rows as $row) { if($count==0) $string=$string."<tr>"; else if($count%$pinrow==0) echo "</tr><tr>"; $string=$string. "<td>"; $ps_product->show_snapshot( $row->product_sku, $show_price, $show_addtocart ); $count++; $string=$string."</td>"; Link to comment https://forums.phpfreaks.com/topic/110307-echoed-values-to-a-string-variable/ Share on other sites More sharing options...
trq Posted June 15, 2008 Share Posted June 15, 2008 Place your call to said function within an output buffer. eg; <?php ob_start(); call_to_some_function_producing_output(); $text = ob_get_contents(); ob_end_clean(); echo $text; ?> Link to comment https://forums.phpfreaks.com/topic/110307-echoed-values-to-a-string-variable/#findComment-565955 Share on other sites More sharing options...
swift1984m Posted June 15, 2008 Author Share Posted June 15, 2008 That worked like soomthness of butter....Thanks a lot man. Link to comment https://forums.phpfreaks.com/topic/110307-echoed-values-to-a-string-variable/#findComment-565958 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.