siwelis Posted April 21, 2010 Share Posted April 21, 2010 I have this code... $prodimg = array(); $prods = mysql_query($prods) or die ("<p>Sorry, an error has occurred!</p>"); while($row = mysql_fetch_assoc($prods)) { stripslashes(extract($row)); while ($tagArray[$prod_id] > 1){ echo "<br />".$tagArray[$prod_id]; $prodoptions.= $prod_name." <select name=\"".$tagArray[$prod_id]."_prodid".$prod_id."\">".$imgoptions."</select><br /><br />"; $prodimg[] = $prod_img; $prodimg[$prod_img] = $tagArray[$prod_id]; $tagArray[$prod_id]--; } } For some reason when I echo it, it comes out like this: 8x10.png - 0 2 - 8x10.png 8x10.png - 1 8x10.png - 2 8x10.png - 3 4-4x5.png - 4 2 - 4-4x5.png 2-5x7.png - 5 2 - 2-5x7.png 2-5x7.png - 6 2-5x7.png - 7 2-5x7.png - 8 8wall.png - 9 2 - 8wall.png 8wall.png - 10 8wall.png - 11 8wall.png - 12 8wall.png - 13 8wall.png - 14 8wall.png - 15 8wall.png - 16 print_r Array ( [0] => 8x10.png [8x10.png] => 2 [1] => 8x10.png [2] => 8x10.png [3] => 8x10.png [4] => 4-4x5.png [4-4x5.png] => 2 [5] => 2-5x7.png [2-5x7.png] => 2 [6] => 2-5x7.png [7] => 2-5x7.png [8] => 2-5x7.png [9] => 8wall.png [8wall.png] => 2 [10] => 8wall.png [11] => 8wall.png [12] => 8wall.png [13] => 8wall.png [14] => 8wall.png [15] => 8wall.png [16] => 8wall.png ) I can't figure out where the results in BOLD are coming from. Does anyone have any clue? Link to comment https://forums.phpfreaks.com/topic/199329-array-producing-extra-data-i-dont-want/ Share on other sites More sharing options...
siwelis Posted April 21, 2010 Author Share Posted April 21, 2010 Figured it out... it should be: $prodimg = array(); $prods = mysql_query($prods) or die ("<p>Sorry, an error has occurred!</p>"); while($row = mysql_fetch_assoc($prods)) { stripslashes(extract($row)); while ($tagArray[$prod_id] > 1){ echo "<br />".$tagArray[$prod_id]; $prodoptions.= $prod_name." <select name=\"".$tagArray[$prod_id]."_prodid".$prod_id."\">".$imgoptions."</select><br /><br />"; $prodimg[] = $prodimg[$prod_img] = $tagArray[$prod_id]; $tagArray[$prod_id]--; } } might even be able to take it a step further... Link to comment https://forums.phpfreaks.com/topic/199329-array-producing-extra-data-i-dont-want/#findComment-1046151 Share on other sites More sharing options...
siwelis Posted April 21, 2010 Author Share Posted April 21, 2010 Never mind. Didn't figure it out. Now it's printing something very different. It got rid of the unwanted characters, but the values are different in the array now. Link to comment https://forums.phpfreaks.com/topic/199329-array-producing-extra-data-i-dont-want/#findComment-1046152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.