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: 3% [?]
RSS feed for comments on this post · TrackBack URI
Leave a reply