Guest User

Untitled

a guest
Jun 20th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. /**
  2. * comma_list_ended()
  3. * returns a string list of the items in an array, using
  4. * a specified last word to substitute the last comma.
  5. *
  6. * eg. a, b, c, d and e
  7. * 1, 2, 3, 4 or 5
  8. *
  9. * @author: Andy Thomas (forrst@antom.co.uk)
  10. * @date: 27/09/2010
  11. */
  12.  
  13. function comma_list_ended($arr,$last = 'and') {
  14. return preg_replace("/,([^,]*)$/", " {$last} $1", (is_array($arr) ? implode($arr,', ') : $arr));
  15. }
Add Comment
Please, Sign In to add comment