Jump to content

What's wrong with this


2sharp

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.