Blog Post RSS ?

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

What do you call this: =>

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?

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. What’s the difference between function.call and function.apply? Function.call and function.apply are a couple of very useful methods,...
  2. Google Closure: How not to write JavaScript What if Google released a JavaScript library that sucked, and...
  3. 5 Tips For Creating An Effective Call To Action Button Jennifer runs through 5 tips that will help your Call...
  4. Getty Images Call For Artists On Flickr Getty Images are making a formal call for artists through...
  5. How to Split WordPress Content Into Two or More Columns Craig provides a useful technique which splits WordPress page or...

This post has 55 responses so far