A while back, I have written an article on https://www.amitmerchant.com/how-to-convert-arrays-to-human-readable-lists-in-javascript/. It’s a built-in feature using the Intl.ListFormat object that lets you do that.
$books = [ 'Harry Potter', 'Bhagavad Gita', 'The Alchemist', 'Birthday Girl' ]; And if we want to deflate it as a human-readable list, here’s how we can do it. use Illuminate\Support\Arr; $bookList = Arr::join($books, ', ', ' and '); // Harry Potter, Bhagavad Gita, The Alchemist and Birthday Girl