Last active
April 7, 2017 07:35
-
-
Save yohangdev/7c6989b8beea7e6a556c to your computer and use it in GitHub Desktop.
Menampilkan elemen-elemen Array dengan elemen terakhir diberi tambahan 'dan' atau 'and'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mantap soul 👍