I have an array of items:
array(
'apples',
'oranges',
'pineapples'
)
that I would like to format like so: "Some of my favorite fruits are apples
, oranges
and pineapples
"
So, using PHP
I would like to be able to transform that array into a reader friendly apples, oranges and pineapples
.
At first I thought I might be able to use array_map
but i'm not sure how I would go about telling what the last and 2nd to last items are (it's easy to add a ,
after each item with array_map
, however you wouldn't want a comma before the last item)
Thoughts?