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. Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/ Share on other sites More sharing options...
Wuhtzu Posted November 10, 2007 Share Posted November 10, 2007 $var[] is an array.... Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388555 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; Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388556 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]; Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388559 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; } Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388561 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'; ?> Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388562 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 Link to comment https://forums.phpfreaks.com/topic/76745-solved-easy-one-variable-hello-or-variablehello/#findComment-388566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.