As I was finalizing some tweaks to a social networking script for a client, I noticed an interesting way that variables are pulled off the db record set which I didn’t know of previously.

extract((array)$row,EXTR_PREFIX_ALL,”row”);

This takes all the variables within the $row array, which I would typically access by $row[varname] and creates a variable called $row_varname. Pretty neat!

I had previously done something similar to this by looping through the array and assiging $GLOBALS[varname] = $value, but this neat little sucker does all that for us, now doesn’t it!

Popularity: 4% [?]

    Bookmark An easy way to loop through db records at del.icio.us    Digg An easy way to loop through db records at Digg.com    Bookmark An easy way to loop through db records at Spurl.net    Bookmark An easy way to loop through db records at reddit.com    Bookmark An easy way to loop through db records at YahooMyWeb