note 119301 deleted from function.implode by peehaa
| From: | peehaa@php.net | Date: | Sun, 28 Apr 2019 10:49:58 +0000 |
| Subject: | note 119301 deleted from function.implode by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210823@lists.php.net to get a copy of this message | ||
Note Submitter: radoslaw dot paluszak at gmail dot com
----
A very neat option to limit the number of pieces being imploded is by using array_slice
(http://php.net/array_slice):
<?php
$picnames = array("pic1.jpg", "pic2.jpg", "pic3.jpg",
"pic4.jpg", "pic5.jpg", "pic6.jpg", "pic7.jpg");
$allpics = implode("|", array_slice($picnames, 0, 5));
?>
Hope it helps!