Jump to content

What is the => Operator?


utahcon

Recommended Posts

ok, the pointer (->) operator is completely different from the "=>" operator. the second is mainly used with arrays. it shows the relationship between a key and its value. for instance, if we were assigning an associative array, we would do something like this:
[code]
$favorites = array("candy" => "chocolate", "color" => "blue");
[/code]

this then assigns the value of "chocolate" to $favorites["candy"] and so forth.

you use the same operator when you're pulling information OUT of an array:
[code]
foreach ($favorites as $key => $value) {
  echo "$key contains \"$value\"<br />\n";
}
[/code]

as for the pointer (->) operator, you need to read up on OOP (Object Oriented Programming) to get a full realization of what all is involved with something like that.

hope this helps!
Link to comment
https://forums.phpfreaks.com/topic/7735-what-is-the-operator/#findComment-28236
Share on other sites

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.