What do you call this: =>

By | | PHP

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?

Written By:

Kevin Yank

Kevin began developing for the Web in 1995 and is a highly respected technical author. He wrote Build your own Database Driven Website using PHP and MySQL, a practical step-by-step guide published by SitePoint, and he's co-author of the SitePoint Tech Times, a bi-weekly newsletter for technically-minded web developers. Kev believes that any good webmaster should have seen at least one episode of MacGyver.

Website
>> More Posts By Kevin Yank

 

{ 54 comments }

GC November 9, 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

AC October 21, 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.

Mc P. October 17, 2005 at 10:48 am

Call it “quitschiboo”

Monkeyhead October 14, 2005 at 4:38 am

i vote for Jipper

Scheisskopf October 13, 2005 at 4:25 am

No, but then again i don’t Hitler did either. Tell you what, let’s call it ASP.

sodster October 11, 2005 at 8:33 pm

does it make coffee?

Scheisskopf October 5, 2005 at 8:15 am

Call it Hitler.

redbone October 3, 2005 at 9:18 pm

Shouldn’t you be checking the Perl manual? Perl used it for associative arrays first

Quaint October 3, 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…

Luke September 30, 2005 at 5:11 pm

Er, the code was [?php => ?] (replace the [] with angle brackets)

Luke September 30, 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!!!

Luke September 30, 2005 at 5:04 pm

Double arrow. I call the -> a single arrow.

Kevin Lehman September 30, 2005 at 2:52 pm

Array Simplifier

SchizoDuckie September 30, 2005 at 4:10 am

Has nobody ever encountered the

Parse error: parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM

error?

( PAAMAYIM_NEKUDOTAYIM == :: a.k.a. double colon )
It comes from hebrew, and means double colon in hebrew.

I suggest something similar for =>
:)

tombr September 29, 2005 at 5:23 pm

arrow thinggy

RuinDweller September 28, 2005 at 12:13 pm

What is the Hebrew for “double arrow”?

HaChetz HaKaful. ;) And now try and say it backwords.

Nova September 28, 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? :))

TheLunchBox September 28, 2005 at 9:52 am

I’m going to revise my previous reccomendation of “Shmoobob” to “+6 Vorpal Dart of Associating”

Tim_Rogovets September 28, 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]

abstraktmedia September 28, 2005 at 7:50 am

Let’s call it Dominic :)

llook September 28, 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.

Steve September 28, 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 …

Elliot Anderson September 28, 2005 at 2:18 am

I call it an accessor

Anonymous September 28, 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.

auricle September 27, 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.

z0s0 September 27, 2005 at 7:10 pm

Expanding on the dart suggestion, I vote for “Dart of Pleasure”.

Dean C September 27, 2005 at 7:04 pm

If you do not have anything to say… [ Tuesday, 27th of September, 2005 - 13:37 - Skien, Norway ]

then say nothing at all. Am I the only one who things that blog posts like this are only there to be a blog post? This site used to have a nice PHP blog but lately the entries that appear have no content whatsoever. Really sad to see this happening again.

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 :)

mrsmiley September 27, 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”.

BerislavLopac September 27, 2005 at 5:06 pm

Can it not be called => like Prince used to be?

The symbol formerly known as “double quote”.

Maarten Manders September 27, 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.

Transpyre September 27, 2005 at 2:54 pm

liking “dart”
nice & simple.

Itshim September 27, 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…

Buddha443556 September 27, 2005 at 11:21 am

In Perl, it’s known as the arrow comma.

TheLunchBox September 27, 2005 at 10:43 am

I like the name Bob or possibly shmoopy

Maybe even combine the two SHMOOBOB!

DerekMartin.ca September 27, 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“?

Maarten Manders September 27, 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.

Tvienti September 27, 2005 at 8:56 am

Dinamegatron Maxipowerbar operator

auricle September 27, 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.

devonmallory September 27, 2005 at 8:37 am

Can it not be called => like Prince used to be?

cranial-bore September 27, 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.

pravin September 27, 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”

chris ward September 27, 2005 at 6:05 am

It’s a pointer, syntax taken from C/C++ I believe

ronanmagee September 27, 2005 at 6:04 am

I just call it a pointer, as in $k points to (=>) $v

Etnu September 27, 2005 at 5:59 am

Spear of Destiny.

cholmon September 27, 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?

pravin September 27, 2005 at 5:00 am

How about “access pointer”?

BerislavLopac September 27, 2005 at 4:30 am

What is the Hebrew for “double arrow”?

Vikrant September 27, 2005 at 4:14 am

Key Seperator

patrikG September 27, 2005 at 3:53 am

array assigner

Richard September 27, 2005 at 3:29 am

Call it Bob.

Owen September 27, 2005 at 2:46 am

Maybe gets?

As in “$key gets $value”.

Owen

Gonik September 27, 2005 at 2:43 am

Most of the times i call it simplifier because it makes navigating through an array a lot simpler. :)

mmj September 27, 2005 at 2:41 am

It’s an arrowhead :)

ssttoo September 27, 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.

Comments on this entry are closed.

{ 1 trackback }