alternator()

alternator($args)

Parameters:
  • $args (mixed) – A variable number of arguments
Returns:

Alternated string(s)

Return type:

mixed

Allows two or more items to be alternated between, when cycling through a loop. Example:

for ($i = 0; $i < 10; $i++)
{
        echo alternator('string one', 'string two');
}

You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.

for ($i = 0; $i < 10; $i++)
{
        echo alternator('one', 'two', 'three', 'four', 'five');
}

Note

To use multiple separate calls to this function simply call the function with no arguments to re-initialize.

doc_CodeIgniter
2016-10-15 16:30:51
Comments
Leave a Comment

Please login to continue.