View Single Post
Old 18-04-2008, 18:10   #9 (permalink)
Naatan
Web Developer
 
Naatan's Avatar
 
Join Date: Jan 2007
Location: Brussels
Posts: 214
Send a message via MSN to Naatan
In my opinion; if you're gonna repeat the exact same piece of code more than twice.. put it into a function..
Code:
function getStuff() { $string = array(); $string['a'] = $a stuff; $string['b'] = $b stuff; $string['c'] = $c stuff; return $string; } if(something) { $str = getStuff(); do something with $str['a'] $str['b'] and $str['c'] } else { do something else } if(another thing) { do something } else { $str = getStuff(); do something with $str['a'] $str['b'] and $str['c'] } if(one last thing) { $str = getStuff(); do something with $str['a'] $str['b'] and $str['c'] } else { do something else }

"Problem" solved
__________________
Developer of Divia CMS,
More info? Visit my blog.
  Reply With Quote