mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding docblock and removing a call to array_slice()
This commit is contained in:
parent
53bfc8cca2
commit
69b72083be
1 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue