In the case you mention it's also about as easy to read/understand as it will ever be-- the contents of the array are right there. I find it gets trickier when the contents of that array are coming in from outside the function or method.
Definitely still useful, but gets harder to track. -- Jeff Slutz JSLEUTH LLC 2105 N Fork Drive Lafayette, CO 80026 c. 970.443.9390 j...@jeffslutz.com On Fri, Jan 31, 2014 at 8:08 AM, Chris Snyder <chsny...@gmail.com> wrote: > On Thu, Jan 30, 2014 at 12:12 PM, Jerry B. Altzman <jba...@altzman.com>wrote: > >> >> 'Variable variables' aren't pure evil; they just provide a level of >> indirection that allows for fine-grained loss of control at runtime. >> > > Not only are they not evil, they're necessary for a lot of Don't Repeat > Yourself optimizations. > > I use this pattern all the time: > > foreach( array('pages', 'posts', 'comments') AS $collection ) { > ${$collection} = $model->load( $collection ); > // do more stuff with ${$collection} here > $template->assign( ${$collection}, $collection ); > } > > It's a little bit harder to read until you get used to it, but because > it's DRY it's much easier to manage over time. > > > _______________________________________________ > New York PHP User Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/show-participation >
_______________________________________________ New York PHP User Group Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk http://www.nyphp.org/show-participation