farkewie Posted November 10, 2007 Share Posted November 10, 2007 hello, before you say it i do have the php manual here but not sure where to start looking. :-) what is the difference between $var[]='hello'; and.. $var='hello'; can someone give me a brief rundown? i am trying to create my own web album fron scratch im looking at sample code but dont just want to copy and paste i want to learn what its doing. Quote Link to comment Share on other sites More sharing options...
Wuhtzu Posted November 10, 2007 Share Posted November 10, 2007 $var[] is an array.... Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 $var[]='hello'; Adds the value to an numerically indexed array You could do this to create an array holding multiple values. $var[] = 'hello'; $var[]='goobye'; $var[]='cruel world'; echo $var[0].' '.$var[1].' '.$var[2]; //outputs goodbye cruel world $var='hello'; Creates a variable that holds a single value; Quote Link to comment Share on other sites More sharing options...
farkewie Posted November 10, 2007 Author Share Posted November 10, 2007 ok so $var[] = 'hello'; $var[]='goobye'; $var[]='cruel world'; echo $var[0].' '.$var[1].' '.$var[2]; using this you have to remember how many times to define a new value because to use it you have echo them individually? echo $var[0].' '.$var[1].' '.$var[2]; Quote Link to comment Share on other sites More sharing options...
coder_ Posted November 10, 2007 Share Posted November 10, 2007 Or you can do this: foreach ($var as $_newVar) { echo $_newVar; } Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 10, 2007 Share Posted November 10, 2007 ok so $var[] = 'hello'; $var[]='goobye'; $var[]='cruel world'; echo $var[0].' '.$var[1].' '.$var[2]; using this you have to remember how many times to define a new value because to use it you have echo them individually? echo $var[0].' '.$var[1].' '.$var[2]; You could assign your own index <?php //numeric indexes $var[0] = 'George'; $var[1] = 'Washinton'; //associative indexes $var['fisrtname'] = 'George'; $var['lastname'] = 'Washington'; ?> Quote Link to comment Share on other sites More sharing options...
farkewie Posted November 10, 2007 Author Share Posted November 10, 2007 Thanks guys that should get me started. now to workout the thumb creation... i must admit i havea perfectly good script that i downloaded. but it has all the extra features i dont want and much more code that is needed. so it will be interesting how mine turns out..lol 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.