About the Author

author photo

Adam Trachtenberg is the Director of the LinkedIn Developer Network, where he oversees developer relations and marketing for the LinkedIn Platform. Before LinkedIn, Adam worked at eBay in platform product management and marketing. Even earlier, he co-founded Student.Com and TVGrid.com. Adam is the author of PHP Cookbook and Upgrading to PHP 5. He lives in San Francisco.

See All Posts by This Author

Stupid PHP one liners: Google calc

A long time ago, I wrote a two line hack that let you use Google as a command line calculator. It eventually ended up in the 2nd and 3rd editions of Google Hacks.

I don’t know what caused by to look at that code again, but here’s the one line version:

print str_replace('<font size=-2> </font>', ',' ,
  preg_replace('(.+<b>.+= (.+?)</b>.+)s', '$1',
    file_get_contents('http://www.google.com/search?q=' .
      urlencode(join(' ', array_splice($argv, 1)))))) . "\n";

Popularity: 8% [?]

Post a Response