Month: September 2008

Building a nested array from a flat one

This post is largely because I want to remember hos to do this, but maybe it’ll be good for someone else out there.

To change an array like this:
Array (
[0] => Array (
[RECORD_DESC] => Root #1
[RECORD_ID] => 1
[LEVEL] => 1
[1] => Array (
[RECORD_DESC] => Root #2
[RECORD_ID] => 2
[LEVEL] => 1
[2] => Array (
[RECORD_DESC] => Root #3
[RECORD_ID] => 7
[LEVEL] => 1
[3] => Array (
[RECORD_DESC] => Under Root #3
[RECORD_ID] => 8
[LEVEL] => 2

Into a nested parent/child array, use this:

$ret = array(‘root’=>array());
$ref[0] =& $ret[‘root’];

foreach($retv as $row) {

$ref[$p][$i] = array(‘data’=>$row,’ch’=>array());
echo ‘

'; print_r($ret); echo '




ZendCon08 and the PHP Community

Day four of this year’s Zend/PHP Conference and Expo has finally come – we all wish it could have been just a bit longer. There was tons of stuff jammed into this year’s event, both in the sessions and activities outside the conference hours. These four days went too quickly for me as it was one of the very rare times that I can sit with the people I talk about and with every day online and just have a beer and shoot the breeze. I have the user group at home that’s fun to go to and I always learn a lot there, but there’s just something different about getting to meet up with developers you know, ones you don’t and people you might never get to see (or not for a long time) because of where they’re from.

See, that’s what these events are really about (or should be about). Yes, the sessions are good – it’s nice to listen to people go one about scalability and security techniques, but what’s really at the heart is the community that the conference inspires. You can walk down the halls and see it. People getting introduced to other (“oh, you should so meet…”) and groups just standing around and talking about things, PHP related and not. It’s was even there at breakfast when people would get their abnormally small coffees, a bagel and sit down with people they may not even know and start talking. During these past four days, we were all equals – it wasn’t about what you know so much as the fact that you were willing to sit down and share a part of you and your experiences with another person.

Unfortunately, there’s only so much time and so many resources to go around and we all have to head home sometime. For some it’s just up the road but others are quite a bit further away than that (and even some, further than that). The people we met and discussions we had start fading away a little bit and those business cards in our pocket become more of “that person”.

I wish there was a way that we could keep this kind of connectivity going even when we’re home in our familiar houses and offices. It’s just not that easy, unfortunately, but the effect can be lessened. Stay in touch with those people! Send them emails asking how that project they mentioned to you is going! Get them in contact with other people you know who could help them out.

It doesn’t matter if you came to the conference and really only met one or two people – stay in contact with them. These conferences (and really the same things applies to user group meeting too) are not just things to come to and sit in rooms all day, isolated in your thoughts. You can take online classes if that’s all you’re looking for. Conferences/meetups/coffee with other developers is about the networks – building those links between you and other people that love the language you love and that can be a huge help if you might need it.

Don’t feel left out if you didn’t get to ZendCon this year – it’s just one of the many many great conferences happening this year. Can’t make it to a conference? Look for a local user group! There’s bound to be one in your area (and if there’s not, look at starting one up). You don’t even have to make it out to events if you don’t want to. I recommend coming over to the IRC network and hopping in on the #phpc channel. There’s tons of great people in there and it’s just fun to talk with other developers about anything and everything.

It’s all about the community.

Why do you use PHP?

A little while back I asked this question on Twitter. I was interested in how other people’s first experiences with PHP compared with my own. I got some great responses – from funny to completely honest. Here’s the list:

  • Skoop: I didn’t choose PHP, PHP chose me (nice, very zen.)
  • Andriess: low entry barrier, and the AWESOME community
  • Felixdv: great community, open-source spirit and low barrier but powerful if needed (as of PHP5 😉 )
  • DragonBe: in PHP I found my likings, where as Perl left me hanging about..
  • Rmehner: Mainly because of deployment issues in the beginning. PHP was everywhere available. (In the beginning I had often web projects)
  • lvtrll: The options at the time were PHP or ASP… which would you choose? =P
  • ijansch: it was the logical choice (or, to be more precise: it gets the thing done, and quickly.)
  • njames: its “FREE” no need for mucking about with licences for VS or IIS or W2K or MSSQLSRVR etc etc #php
  • weierophinney: out of necessity.
  • padraicb: At the time (1999) PHP happened to coincide with the activities of friends online – seemed natural I’d help them cut and paste 😉
  • iephp: I used to do Java and Perl and a friend of mind told me PHP was easy and fun. I tried it out, turned out well 😉
  • akrabat: Wasn’t that much choice back in PHP3 days. Perl / CGI didn’t appeal and the only other choice on my host was PHP…
  • jlleblanc: someone suggested it in college and it was easy/inexpensive to get into.
  • sweatje: My Unix admin pointed me towards LAMP when I was looking for a free alternative to IIS/ASP for a home business accounting system
  • chartjes: My first job out of college needed a web site and had no money to pay for licenses for Windows server (this is 1998)
  • ramsey: Switched from ASP to PHP b/c I didn’t want to learn ASP.NET, Tomcat was a bitch, & PHP had everything we needed built in (& more)
  • calevans: because upgrading from NT to Server 2000 was going to cost me $15,000 + hardware.

I think I got them all, but if you didn’t get to contribute, definitely leave a comment with your first introductions to this great language of ours!