erdomester Posted May 14, 2009 Share Posted May 14, 2009 Hi everyone, I would like to create a table from three arrays. These are: $Size: 35,38,42 $Title: S,M,L $Price: 200,210,230 I want it to look like this: Size Title Price 35 S 200 38 M 210 42 L 230 I've been trying for hrs now but without luck. Link to comment https://forums.phpfreaks.com/topic/158112-solved-how-to-create-a-table-with-for-loop/ Share on other sites More sharing options...
Jibberish Posted May 14, 2009 Share Posted May 14, 2009 This assumes that the arrays are the same size and in the right order relative to each other <?php $Size = array(35, 38, 42); $Title = array('S', 'M', 'L'); $Price = array(200, 210, 230); echo '<table><tr><td>Size</td><td>Title</td><td>Price</td></tr>'; for ($i = 0; $i<sizeof($Size); $i++) { echo '<tr><td>' . $Size[$i] . '</td><td>' . $Title[$i] . '</td><td>' . $Price[$i] . '</td><td></tr>'; } echo '</table>'; ?> Link to comment https://forums.phpfreaks.com/topic/158112-solved-how-to-create-a-table-with-for-loop/#findComment-834007 Share on other sites More sharing options...
erdomester Posted May 14, 2009 Author Share Posted May 14, 2009 Thank you! Link to comment https://forums.phpfreaks.com/topic/158112-solved-how-to-create-a-table-with-for-loop/#findComment-834013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.