meaning of '=>'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
father
Forum Newbie
Posts: 5
Joined: Fri May 23, 2003 10:15 pm
Location: Australia

meaning of '=>'

Post by father »

I am creating an array like this

$prices = array ('tires'=>100, 'oil'=>100, 'spark plugs'=>4 );

or like this

$prices['tires']=100;
$prices['oil']=10;
$prices['spark plugs']=4;


first one I specificy the '=>' in the other way I can just use '='

Not sure what '=>' is suppose to do more? then just '='
Going through my php book I don't have a '=>' operator

I have '<=' and '>='

Is '=>' not an operator?

Thanks
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

in:

Code: Select all

$prices = array ('tires'=>100, 'oil'=>100, 'spark plugs'=>4 );
"=>" means... key with value .. with that symbol you asign a value to a key. its not an operator.

when you asign values one by one, you make this:

Code: Select all

$prices&#1111;'key'] = 'value';
here you asign array with some key the value you want... check this out http://www.php.net/types.array
father
Forum Newbie
Posts: 5
Joined: Fri May 23, 2003 10:15 pm
Location: Australia

Post by father »

K, thx for that!
Post Reply