Thread: Wordpress PHP
View Single Post
Old 05-02-2009, 02:05 AM  
GrouchyAdmin
Now choke yourself!
 
GrouchyAdmin's Avatar
 
Industry Role:
Join Date: Apr 2006
Posts: 12,085
You can do it the hard way if you really want, but render blogroll links allows pre, and post wrapping. If you need the logic to that, here's some an ancient routine I made in about 2004, it will return 'row1' or 'row2' by default - you ca specify the assigned variable you want displayed by naming it:

Code:
// This simple creature returns a numeric of 1, or 2, based upon the
// global index for $gl['row']; You may set the prefix for this, or if passed as a boolean of TRUE for a secondary param; it will reset to '1'
// -----------------
function thisrow($name=FALSE, $reset=FALSE){
  global $gl;
  $name = (isset($name)) ? $name : "row"
  $gl['__row'] = ($reset) ? 1 : (($gl['__row']++%2) + 1);
  return($name . $gl['__row']);
}
Here's a sample:

Code:
$array = array("one","two","three","four","five");
foreach ($array as $value) {
  echo "<div class =".thisrow("pie").">$value</div>";
}
__________________
GrouchyAdmin is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote