Month: September 2006

A Single-function JSON Freakshow

Want to see something scary and hacky? Check this out – it takes in a PHP array and makes a JSON message out of it:

function build($arr,&$str,$lvl=0,$in_arr=”){
foreach($arr as $key => $value){
$str.=(($in_arr==1)?'{‘:”).'”‘.$key.'”: ‘;;

if(count($value)>1){ $str.='[‘;
}elseif(count($value)==1){ $str.=”;
}else{ $str.='{‘; }


if(count($value)>1){ $str.=’]’;
}elseif(count($value)==1){ $str.=”;
}else{ $str.=’}’; }

$str.=($in_arr==1) ? ‘}’ : ”;
$str.=(next($arr)) ? ‘,’ : ”;
$str.=($lvl>1) ? ‘{‘ : ”;
$str.=($lvl>1) ? ‘}’ : ”;
$str.=(next($arr)) ? ‘,’ : ”;

And, of course, a sample of how to use it:


echo ‘{‘.$str.’}’;

Be afraid. Be very afraid 🙂


My New Addiction

My wife and I visited England (up by York and Manchester) and much fun was had by all.

Too bad I came back with an addiction. It’s taken hold of me and is constantly with me. I can’t stop thinking about it and I wonder when I can get my next fix. I feel the constant need to spend lots of money to feed my habit (and with the exchange rate right now, that’s not a good thing), and I just can’t get the stuff I need over here.

That’s right, I’m an addict.
I’m addicted to Tom Holt books (not quite what you were expecting, eh?)

Yes, I casually picked up one of his books (“Falling Sideways“) in a shop while we were over there and finished it in about two days. I have to say, I haven’t read anything so delightfully light-hearted and funny in a long time (we’ll, that wasn’t something I’d read a million times over).

Alas, my probem still remains – the US store doesn’t carry them all (only like 10 or so) and ordering them from overseas is a bit expensive right now for us U.S-ers. I’ve ordered “Omnibus 5: Tall Stories” and “The Portable Door” from Amazon, and I’m counting the days.

It’s always fun to discover a writer you really enjoy, especially when you find out that that writer has loads of books for you to catch up on 🙂

Here’s to the unsung programmers….

A community is not about the members that get the most noteriety.

A community is not about the programmers that do the cool things or the bleeding edge stuff.

A community is not a select few.

A community is a group of people, centered around a cause, looking to do the best that they can to belong and to find thier place in the rankings that the community imposes.

See, the PHP community is like any other. There are those out there that are the notables, the ones that get mentioned in press releases or in lots of news postings (yes, guilty, I know). But for each of the ones that gets creadit for the advancements in the languge, there are tens or hundreds more behind them pushing and helpong to get things done.

Here’s to the unsung heroes of the PHP community – those developers that remain nameless, but contribute their 110% to the language or to developing their applications. They work thing fingers to the bone (well, okay, so maybe not quite that much) trying to further the cause of PHP. There are countless developers looking to forge their own path through the PHP wilderness without getting the recongition they deserve.

Yes, I’m guilty of focusing on a “chosen few” that have proven themselves in the past and have made a name for themselves in the community, but there are tons more out there, woorking on their own projects, making their own ways that aren’t acknowledged and that aren’t brought into the public spectrum.

So, here’s to you the unsung programmers out there – thank you for all that you do to help the PHP community become what it is.

If you’re at the ZendCon 2006 this year, find me and I’ll buy you a drink.