数组中的可读列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了数组中的可读列表相关的知识,希望对你有一定的参考价值。

  1. // ex: human_list(array('one', 'two', 'three)) --> one, two, and three
  2. function human_list($itemList) {
  3. switch(count($itemList)) {
  4. case 0: return '';
  5. case 1: return $itemList[0];
  6. default:
  7. $last = array_pop($itemList);
  8. return implode(', ', $itemList).' and '.$last;
  9. }
  10. }

以上是关于数组中的可读列表的主要内容,如果未能解决你的问题,请参考以下文章