gabrielkolbe Posted July 29, 2007 Share Posted July 29, 2007 Hi, I have this script, it works outside the function, no probs with it BUT I need to place the output of the function in one string in order to return in how do I do it?? $input = array('apple', 'orange', 'monkey', 'potato', 'cheese', 'badger', 'turnip'); $cols = 2; function table_columns($input, $cols) { [color=red] $i=0; echo = '<table border=1> <tr>'; foreach ($input as $in){ $i++; echo = '<td>'.$in.'</td>'; if($i==$cols){ echo = '</tr><tr>'; $i=0; } } echo = '</tr><table>';[/color] the bits in red should be placed in a variable called output return $output; } Link to comment https://forums.phpfreaks.com/topic/62332-how-do-i-place-various-php-action-in-one-variable/ Share on other sites More sharing options...
trq Posted July 29, 2007 Share Posted July 29, 2007 function table_columns($input, $cols) { $i=0; $output .= '<table border=1> <tr>'; foreach ($input as $in){ $i++; $output .= '<td>'.$in.'</td>'; if($i==$cols){ $output .= '</tr><tr>'; $i=0; } } $output .= '</tr><table>'; return $output; } Link to comment https://forums.phpfreaks.com/topic/62332-how-do-i-place-various-php-action-in-one-variable/#findComment-310138 Share on other sites More sharing options...
gabrielkolbe Posted July 29, 2007 Author Share Posted July 29, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/62332-how-do-i-place-various-php-action-in-one-variable/#findComment-310148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.