2sharp Posted September 18, 2008 Share Posted September 18, 2008 Sorry if this is dumb-ass but I can't see where the problem is with this. Just a simple page where I'm trying to understand arrays but my while loop fails. I'm just closing the while loop ! Parse error: syntax error, unexpected '}' in /Users/jon/Sites/brokenbench.dev/web/array.php on line 43 J 1: <?php 2: 3: $images = array( 4: array('id' => '01', 'width' => '600', 'height' =>'405'), 5: array('id' => '02', 'width' => '600', 'height' =>'405'), 6: array('id' => '03', 'width' => '600', 'height' =>'405'), 7: array('id' => '04', 'width' => '600', 'height' =>'405'), 8: array('id' => '05', 'width' => '600', 'height' =>'405'), 9: array('id' => '06', 'width' => '600', 'height' =>'405'), 10: array('id' => '07', 'width' => '600', 'height' =>'405'), 11: array('id' => '08', 'width' => '600', 'height' =>'405'), 12: array('id' => '09', 'width' => '600', 'height' =>'405'), 13: array('id' => '10', 'width' => '600', 'height' =>'405'), 14: array('id' => '11', 'width' => '600', 'height' =>'405'), 15: array('id' => '12', 'width' => '600', 'height' =>'405'), 16: array('id' => '13', 'width' => '600', 'height' =>'405'), 17: array('id' => '14', 'width' => '600', 'height' =>'405'), 18: array('id' => '15', 'width' => '600', 'height' =>'405'), 19: array('id' => '16', 'width' => '600', 'height' =>'405'), 20: array('id' => '17', 'width' => '600', 'height' =>'405'), 21: array('id' => '18', 'width' => '600', 'height' =>'405'), 22: array('id' => '19', 'width' => '600', 'height' =>'405'), 23: array('id' => '20', 'width' => '600', 'height' =>'405') 24: ); //closes images array 25: //$image_id = $images["$i"]['id']; 26: //echo "$image_id"; 27: echo $images['3']['id']; // Outputs 04 28: echo "<br />"; 29: echo $images['4']['height']; 30: echo "start experiment"; 31: echo "<br />"; 32: $i=0; 33: while($i <= 12) { 34: 35: 36: $image_id = $images["$i"]['id']; 37: $width = $images["$i"]['width']; 38: $height = $images["$i"]['height']; 39: $images["$i"]['height']; 40: echo "Image id is $image_id and width is $width and height is $height<br />"; 41: 42: $i++ 43: } 44: 45: 46: ?> EDIT by zanus: please learn to use the code tags Quote Link to comment Share on other sites More sharing options...
peranha Posted September 18, 2008 Share Posted September 18, 2008 42: $i++ I believe that should be 42: $i++; Quote Link to comment Share on other sites More sharing options...
2sharp Posted September 18, 2008 Author Share Posted September 18, 2008 Oh man... sometimes I go blind doing this stuff. Thanks peranha. Sorry for being a doofus everyone... J Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.