I am still a newbie to PHP, and I have a foreach loop issue. The section of code is the following: foreach($word[0] as $value) { foreach($num[0] as $value2) { $tags = array('<td>','</td>','<td width=\'85\'>','<td align=right>'); echo str_replace($tags, "",$value)." ".str_replace($tags, "",$value2)."<br>".$vbCrLf; } } Code (markup): The echoed results show each word ($value) as expected, but the number ($value2) next to each word is the same. For example: word1 45 word2 45 word3 45 After it loops througn each word, it then echoes the first word, with the numbers changing as they should. For example: word1 65 word1 49 word1 23 I am trying to get the result to show each word next to each number like: word1 65 word2 49 word3 23 I tried using arrays to no success, finding I couldn't put the values of $word[0] and $num[0] into an array correctly if it's even possible. PHP Gurus, I would greatly appreciate any suggestions to this problem. Thanks!
Is this what you want to do? <?php $max = count($word[0]); for ($i=0;$i<$max;$i++) { $tags = array('<td>','</td>','<td width=\'85\'>','<td align=right>'); echo str_replace($tags, '',$word[0][$i]).' '.str_replace($tags, '',$num[0][$i]).'<br>'.$vbCrLf; } ?> PHP:
the best way to merg 2 foreach make it function like that function kill_me($ok){ foreach(){ } kill_me(); }