Skip to content

Instantly share code, notes, and snippets.

@yohangdev
Last active April 7, 2017 07:35
Show Gist options
  • Save yohangdev/7c6989b8beea7e6a556c to your computer and use it in GitHub Desktop.
Save yohangdev/7c6989b8beea7e6a556c to your computer and use it in GitHub Desktop.
Menampilkan elemen-elemen Array dengan elemen terakhir diberi tambahan 'dan' atau 'and'
<?php
$last = array_slice($array, -1);
$first = join(', ', array_slice($array, 0, -1));
$both = array_filter(array_merge(array($first), $last));
echo join(', dan ', $both);
@ramadani
Copy link

ramadani commented Apr 7, 2017

mantap soul 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment