ListAppend is a rather simple utility function, however when you are dealing with lists, it can prove a great ally. This is a function that I pulled out of a class of list functions. I will publish the entire class once I get the individual functions published. The default delimiter for the ListAppend function is a ','. The delimiter length should be 1 character. Regardless of the size of the delimiter, the function will only use the first character. | ||||||||||||
The Function: | ||||||||||||
<php | ||||||||||||
Usage: | ||||||||||||
| ||||||||||||
ListAppend works great to add values to a list. This function will default to a ',' for a delimiter! <?php |
Saturday, December 22, 2007
ListAppend
Subscribe to:
Post Comments (Atom)
3 comments:
For me, the function did not print any delimiters. I had to remove the
$delimiter = substr($delimiter,1);
line.
I also made a slight modification to make the function operate correctly on empty lists:
public static function ListAppend($list,$value,$delimiter= ",") {
if (strlen($list) > 0) {
$nList = $list . $delimiter . $value;
} else {
$nList = $list . $value;
}
return $nList;
}
Post a Comment