AleksBg Posted April 26, 2007 Share Posted April 26, 2007 Hi everybody. Since i am a begginer i need help on a simple issue. I am trying to combine arrays in one output. $mail_1 = array('name' , 'last name' , 'city' ); $mail_2 = array($f1,$f2,$f3); The idea is to make output in the table: <table> <tr> <td>name (1st value from $mail_1 array): </td> <td>$f1 </td> </tr> </table> Now, which loop should i use, since i am not very familiar with them... Thanks Link to comment https://forums.phpfreaks.com/topic/48753-arrays-and-loops/ Share on other sites More sharing options...
taith Posted April 26, 2007 Share Posted April 26, 2007 that should suffice i would think $mail_1 = array('name' , 'last name' , 'city' ); $mail_2 = array($f1,$f2,$f3); echo '<table>'; for($i=0; $i<=count($mail_1)-1; $i++){ echo '<tr>'; echo ' <td>'.$mail_1[$i].'</td>'; echo ' <td>'.$mail_2[$i].'</td>'; echo '<tr>'; } echo '</table>'; Link to comment https://forums.phpfreaks.com/topic/48753-arrays-and-loops/#findComment-238932 Share on other sites More sharing options...
AleksBg Posted April 26, 2007 Author Share Posted April 26, 2007 works fine, tnx! Link to comment https://forums.phpfreaks.com/topic/48753-arrays-and-loops/#findComment-238933 Share on other sites More sharing options...
taith Posted April 26, 2007 Share Posted April 26, 2007 no problemo! Link to comment https://forums.phpfreaks.com/topic/48753-arrays-and-loops/#findComment-238935 Share on other sites More sharing options...
Barand Posted April 26, 2007 Share Posted April 26, 2007 this more efficient as it doesn't count the array values every loop for($i=0, $k=count($mail_1); $i<$k; $i++){ Link to comment https://forums.phpfreaks.com/topic/48753-arrays-and-loops/#findComment-238962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.