Blog Post RSS ?

Blogs » PHP » What do you call this: =>
 

What do you call this: =>


  • Save to
    Del.icio.us

by Kevin Yank

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?

Tags:

This post has 55 responses so far

  1. 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.

     
  2. It’s an arrowhead :)

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

     
  4. Maybe gets?

    As in “$key gets $value”.

    Owen

     
  5. Call it Bob.

     
  6. array assigner

     
  7. Key Seperator

     
  8. What is the Hebrew for “double arrow”?

     
  9. How about “access pointer”?

     
  10. 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?

     
  11. Spear of Destiny.

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

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

     
  14. Yes. Right. That’s why I said “Access Pointer”. As “->” this is pointer.
    Using “=>” we access the element of array. Hence “Access Pointer”

     
  15. Do we need to call it anything? If so I’d say The Associator for obvious reasons.
    Failing that I suggest ted.

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

     
  17. 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.

     
  18. Dinamegatron Maxipowerbar operator

     
  19. I agree that this post is kinda pointless.

    However:

    - association operator
    - tuple operator
    - mapping operator
    - index operator
    - hash operator
    - etc.

     
  20. 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“?

     
  21. I like the name Bob or possibly shmoopy

    Maybe even combine the two SHMOOBOB!

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

     
  23. 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…

     
  24. liking “dart”
    nice & simple.

     
  25. 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.

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

    The symbol formerly known as “double quote”.

     
  27. 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”.

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

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

     
  30. >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.

     
  31. 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.

     
  32. I call it an accessor

     
  33. 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 …

     
  34. I call it “rovná se větší než”, it means “equals to greater than” in English. But arrow or dart would be better.

     
  35. Let’s call it Dominic :)

     
  36. 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]

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

     
  38. 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? :))

     
  39. What is the Hebrew for “double arrow”?

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

     
  40. arrow thinggy

     
  41. 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 =>
    :)

     
  42. Array Simplifier

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

     
  44. 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!!!

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

     
  46. 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…

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

     
  48. Call it Hitler.

     
  49. does it make coffee?

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

     
  51. i vote for Jipper

     
  52. Call it “quitschiboo”

     
  53. When I was first learning Perl, my professor referred to ‘=>’ and the ‘rocket ship operator’. I’ve always liked that.

     
  54. $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

     
  55. […] 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. […]

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Logo Design, Web page Design and more!

99designs

  • Custom logo designs created ‘just for you’.
  • Pick the design you like best.
  • Only pay if you’re satisfied with the result.

Want More Traffic?

Get up to five quotes from qualified SEO specialists, with no obligation!

Get A Free SEO Quote Now!