Adding docblock and removing a call to array_slice()

This commit is contained in:
mark_story 2009-11-24 22:06:55 -05:00
parent 53bfc8cca2
commit 69b72083be

View file

@ -328,11 +328,13 @@ class TextHelper extends AppHelper {
* Creates a comma separated list where the last two items are joined with 'and', forming natural English
*
* @param array $list The list to be joined
* @return string
* @param string $and The word used to join the last and second last items together with. Defaults to 'and'
* @param string $separator The separator used to join all othe other items together. Defaults to ', '
* @return string The glued together string.
* @access public
*/
function toList($list, $and = 'and', $separator = ', ') {
return implode($separator, array_slice($list, null, -1)) . ' ' . $and . ' ' . array_pop(array_slice($list, -1));
return implode($separator, array_slice($list, null, -1)) . ' ' . $and . ' ' . array_pop($list);
}
}
?>