As languages go, PHP has more syntactic sugar than some. Esoteric constructs like list(…) are all over the place, making developers’ jobs easier, but tripping up beginners at the same time.
A particularly useful construct is the foreach loop, which provides a quick way to loop through an array (or, as of PHP5, an object):
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
With associative arrays, you can get both the key and value of each item in the array with a little of the aforementioned syntactic sugar:
$a = array(
"one" => 1,
"two" => 2,
"three" => 3,
"seventeen" => 17
);
foreach ($a as $k => $v) {
echo "$k => $v\n";
}
Okay, so if you code PHP regularly I probably haven’t told you anything you don’t already know. But here’s the twist: what do you call the => operator in that last code sample? C’mon — it must have a name, right? As it turns out, no official name is documented in the PHP manual… so what do you call it?
Reportedly it’s called the “double arrow” in the source code to PHP, but that’s only slightly better than “that little arrowey thing.” What do you think it should be called?
If you liked this blog, share the love:



September 27th, 2005 at 2:33 am
Hehe, true, it doesn’t have a name. You don’t name it, you just use it daily… Need suggestions? OK.
A bolt? :D
A shaft?
Dart?
OK, a “flash”. For one, it sounds somewhat close to the French for arrow, “flêche” (but is better than “flesh”). And then it allows you to quickly navigate an array, right, in a blink of an eye, in a flash.
September 27th, 2005 at 2:41 am
It’s an arrowhead :)
September 27th, 2005 at 2:43 am
Most of the times i call it simplifier because it makes navigating through an array a lot simpler. :)
September 27th, 2005 at 2:46 am
Maybe gets?
As in “$key gets $value”.
Owen
September 27th, 2005 at 3:29 am
Call it Bob.
September 27th, 2005 at 3:53 am
array assigner
September 27th, 2005 at 4:14 am
Key Seperator
September 27th, 2005 at 4:30 am
What is the Hebrew for “double arrow”?
September 27th, 2005 at 5:00 am
How about “access pointer”?
September 27th, 2005 at 5:08 am
I’ve taken to calling it “arrow”, but a single-syllable alternative would be welcome.
On a similar note, what do you call “->”? I’m sure it’s got it’s official name, but if you were reading this out loud:
$someObj->anotherObj->aDifferentObj->someVal
how would it sound?
September 27th, 2005 at 5:59 am
Spear of Destiny.
September 27th, 2005 at 6:04 am
I just call it a pointer, as in $k points to (=>) $v
September 27th, 2005 at 6:05 am
It’s a pointer, syntax taken from C/C++ I believe
September 27th, 2005 at 6:21 am
Yes. Right. That’s why I said “Access Pointer”. As “->” this is pointer.
Using “=>” we access the element of array. Hence “Access Pointer”
September 27th, 2005 at 7:53 am
Do we need to call it anything? If so I’d say The Associator for obvious reasons.
Failing that I suggest ted.
September 27th, 2005 at 8:37 am
Can it not be called => like Prince used to be?
September 27th, 2005 at 8:53 am
Derick Rethans just savaged this;
http://derickrethans.nl/if_you_do_not_have_anything_to_say.php
Over in the PHP Application Design forum, we’re wondering what happen to PHPPatterns.
http://www.sitepoint.com/forums/showthread.php?t=296849
Another reason for bemoaning Harry’s disappearance.
September 27th, 2005 at 8:56 am
Dinamegatron Maxipowerbar operator
September 27th, 2005 at 9:36 am
I agree that this post is kinda pointless.
However:
- association operator
- tuple operator
- mapping operator
- index operator
- hash operator
- etc.
September 27th, 2005 at 10:07 am
Maybe “wang“, a la Penny Arcade.
Or perhaps “squid”.
If you rotate it counter-clockwise, “house” would work.
I like the “dart” suggestion above, too.
Seriously, though, what it does is associate one thing with another, so why not call it an “associator“, or a “relation“?
September 27th, 2005 at 10:43 am
I like the name Bob or possibly shmoopy
Maybe even combine the two SHMOOBOB!
September 27th, 2005 at 11:21 am
In Perl, it’s known as the arrow comma.
September 27th, 2005 at 1:41 pm
I personally like cranial-bore’s “The Associator”.
To the people complaining about the blog content:
Dam man, can you never have a little fun. I have never seen a group of people complain about everything. When it is something a light hearted there are a bunch of complaints about substance. If the blog is about some actual PHP technique, or code, then all the posts are about how wrong the author is. Very rarely can there be an actual debate, without it becoming offensive.
Yeah we all liked Hary, but complaining that he is no longer around does no good.
I apologize for this post, I am just really tired of this type of thing…
September 27th, 2005 at 2:54 pm
liking “dart”
nice & simple.
September 27th, 2005 at 4:50 pm
Itshim: I like fun when it’s funny but this could’ve been a non-funny post scriptum for a regular blogpost.
My point is: Give anyone of the readers a chance to publish some smart concept, idea or comment and it’d end up more interesting than the last five blogposts. I would have enough up my sleeve for my part.
September 27th, 2005 at 5:06 pm
The symbol formerly known as “double quote”.
September 27th, 2005 at 6:23 pm
Well said Itshim. Sometimes you just have to have a bit of fun.
For those complaining about the content of this blog, how about you stop critising the authors for a change and actually make some useful suggestions about the content you want to read about? The reason Andrew’s blog does so well is because people ask him to blog about certain topics, and he does. I’m sure the PHP bloggers here would be more than willing to comply with requests for content.
There is always an alternative, that you put up your own hand to write articles or blog content yourself for this community.
That said, I would have considered this post a valid question. As Kevin mentioned, its not documented what to call it, yet there are names given to :: like “Scope Resolution Operator” (like anyone could remember what its original hebrew name was). I spend a good portion of my day teaching others how to code in PHP, and it can be quite frustrating having to constantly refer to “the arrow thingy”. I guess based on the name change for ::, logic would probably call it the “Index Association Operator”.
September 27th, 2005 at 7:04 pm
Seems a bit ironic to me. Derek blogging on how pointless a blog post is, seems pretty pointless to me.
Anyways… Kevin raises a good point here. It has no documented name :)
September 27th, 2005 at 7:10 pm
Expanding on the dart suggestion, I vote for “Dart of Pleasure”.
September 27th, 2005 at 8:06 pm
>Derek blogging on how pointless a blog post is, seems pretty pointless to me.
Sure and it’s his blog which he can do with as he likes. So can Sitepoint, but I would have thought that Mr Yank and his colleagues were aiming somewhat higher than vanity publishing.
September 28th, 2005 at 12:42 am
The programmers who created => ought to have named it! They saw into the future people writing long blog posts about its name, therefore left it open for good humor. ;-)
I generally refer to it as “the array arrow” or “associative arrow” among coworkers.
September 28th, 2005 at 2:18 am
I call it an accessor
September 28th, 2005 at 4:54 am
Using Google’s or Altavista Bablefish’s translator function you get the following if you use : “equaliser arrow”
English to German : Entzerrerpfeil
English to Italian : freccia del compensatore
English to French : flèche d’égaliseur
English to Greek : βέλος εξισωτών
English to Russian : стрелка выравнивателя
Some of these have a ring to them …
September 28th, 2005 at 5:38 am
I call it “rovná se větší než”, it means “equals to greater than” in English. But arrow or dart would be better.
September 28th, 2005 at 7:50 am
Let’s call it Dominic :)
September 28th, 2005 at 9:17 am
Great post and creat comments guys :tup:
I’d call this thing “is”. It’s short and this way the code can be read ok:
[code]”one” is 1,
“two” is 2, etc..
foreach ($a as $k is $v) {
}[/code]
September 28th, 2005 at 9:52 am
I’m going to revise my previous reccomendation of “Shmoobob” to “+6 Vorpal Dart of Associating”
September 28th, 2005 at 11:21 am
though it is recommed to use
coz it don’t copy the array before extracting
while(list($key, $value) = each($array)) {
}
———————————————-
how about “::” (double double dot? :))
September 28th, 2005 at 12:13 pm
HaChetz HaKaful. ;) And now try and say it backwords.
September 29th, 2005 at 5:23 pm
arrow thinggy
September 30th, 2005 at 4:10 am
Has nobody ever encountered the
error?
( PAAMAYIM_NEKUDOTAYIM == :: a.k.a. double colon )
It comes from hebrew, and means double colon in hebrew.
I suggest something similar for =>
:)
September 30th, 2005 at 2:52 pm
Array Simplifier
September 30th, 2005 at 5:04 pm
Double arrow. I call the -> a single arrow.
September 30th, 2005 at 5:09 pm
Ok, I solved it! Run this code ?> and you get:
Parse error: parse error, unexpected T_DOUBLE_ARROW
So there you have it folks. A T-Double-Arrow or double arrow for short. I was right and you were all wrong. Bwaaaa!!!
September 30th, 2005 at 5:11 pm
Er, the code was [?php => ?] (replace the [] with angle brackets)
October 3rd, 2005 at 5:45 am
It’s just the “equals and larget than sign” operator.. What I mean is, it doesn’t have a name, so I use a descriptive one describing what it is made of, instead of what it does…
October 3rd, 2005 at 9:18 pm
Shouldn’t you be checking the Perl manual? Perl used it for associative arrays first
October 5th, 2005 at 8:15 am
Call it Hitler.
October 11th, 2005 at 8:33 pm
does it make coffee?
October 13th, 2005 at 4:25 am
No, but then again i don’t Hitler did either. Tell you what, let’s call it ASP.
October 14th, 2005 at 4:38 am
i vote for Jipper
October 17th, 2005 at 10:48 am
Call it “quitschiboo”
October 21st, 2005 at 9:31 am
When I was first learning Perl, my professor referred to ‘=>’ and the ‘rocket ship operator’. I’ve always liked that.
November 9th, 2005 at 3:05 am
$k => $v\n$k says, “Gimme all your value(able)s! or I’ll tell the compiler!” to $v
Captain is the rank (post) of all php patterns.
” => “ is called JackSparrow! (note, the spaces are part of the pattern :)
[“=>” would be just sparrow..]
I call it Captain JackSparrow
November 22nd, 2005 at 9:23 pm
[…] It all began some time ago, with a perfectly innocent post to SitePoint’s PHP blog. Little did Kev know that his lighthearted comments would eventually see the addition of Maarten Manders, Swiss Computer Science student and PHP guru, to the ranks of the SitePoint Bloggers. […]