Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * comma_list_ended()
- * returns a string list of the items in an array, using
- * a specified last word to substitute the last comma.
- *
- * eg. a, b, c, d and e
- * 1, 2, 3, 4 or 5
- *
- * @author: Andy Thomas (forrst@antom.co.uk)
- * @date: 27/09/2010
- */
- function comma_list_ended($arr,$last = 'and') {
- return preg_replace("/,([^,]*)$/", " {$last} $1", (is_array($arr) ? implode($arr,', ') : $arr));
- }
Add Comment
Please, Sign In to add comment