Skip to content

Instantly share code, notes, and snippets.

@albabar
Created June 5, 2014 10:51
Show Gist options
  • Select an option

  • Save albabar/90b43b8f1fa4f77ca7da to your computer and use it in GitHub Desktop.

Select an option

Save albabar/90b43b8f1fa4f77ca7da to your computer and use it in GitHub Desktop.
Au Increment in HTML tables, like foreach loops. If you want to use it with loop and want to reset the counter, please reset it outside loop. Made it for laravel blade, is it's pain to assign a variable in blade.
<?php
function increment($reset = false, $l = 0) {
static $i;
if($reset) $i = $l;
else return ++$i;
return $reset;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment