adding and to TextHelper::toList #1934

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5177 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-05-24 22:55:05 +00:00
parent e45062f3ef
commit 624e02374a

View file

@ -212,15 +212,14 @@ class TextHelper extends AppHelper {
* @param array $list The list to be joined * @param array $list The list to be joined
* @return string * @return string
*/ */
function toList($list) { function toList($list, $and = 'and') {
$r = ''; $r = '';
$c = count($list) - 1; $c = count($list) - 1;
foreach ($list as $i => $item) { foreach ($list as $i => $item) {
$r .= $item; $r .= $item;
if ($c > 0 && $i < $c) if ($c > 0 && $i < $c)
{ {
$r .= ($i < $c - 1 ? ', ' : ' and '); $r .= ($i < $c - 1 ? ', ' : " {$and} ");
} }
} }
return $r; return $r;