Jump to content

[SOLVED] easy one! $variable[]= 'hello'; or $variable='hello';


farkewie

Recommended Posts

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.

$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;

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];

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';

?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.