KBD

Keith Devens .com

Saturday, November 22, 2008 Flag waving
"Yes, it's terribly simple. The good guys are always stalwart and true, the bad guys are easily distinguished by... – Giles (BtVS: Lie to Me)
← Fraps!I need an editorial policy →

Daily link icon Thursday, October 9, 2003

array_flip

One of the things that's neat about PHP is that it has all these neat little functions in it that do things... things which you could do in just a few lines of code if you had the inclination, but PHP is nice enough to include them for you. It makes working in a generally unpleasant language somewhat more pleasant.

For instance, I have a function in one of my "model"s return a list of categories for my weblog. It returns it as an associative array mapping category ids to category names. For an API I'm writing for something else, I wanted it in the opposite order, mapping category names to category ids. array_flip is one of those simple things I'm talking about.

Unfortunately, the impression I get is that people don't generally get a handle on all of the functions that exist, and IIRC I often see people writing code to do what a built-in function does. The manual is your friend.

← Fraps!I need an editorial policy →

Comments XML gif


Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

Calif. Supreme Court to take up gay marriage ban

I would argue the point is not​definitional.  While the word​marriage is su...

Justin: Nov 20, 4:37pm

Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Generated in about 0.167s.

(Used 8 db queries)

mobile phone