note 124488 added to function.implode
| From: | radon8472@php.net | Date: | Sat, 07 Dec 2019 12:12:24 +0000 |
| Subject: | note 124488 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-213412@lists.php.net to get a copy of this message | ||
To avoid
Deprecated: implode(): Passing glue string after array is deprecated. Swap the
parameters
Errors in php version 7.4 and above, but keep the code compatible with lower versions, I wrote a
small wrapper function to handly the swapped arguments.
<?php
function implode_wrapper($glue , $pieces) {
return (version_compare(PHP_VERSION, '7.3.99', '>'))
? implode($glue, $pieces)
: implode($pieces, $glue);
}
// usage:
echo implode_wrapper(", ", array(1,5,6,9));
?>
Of course you could use a shorter functionname for this e.g. "implodew"
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.195 (proxied: 92.193.201.228)
----
Manual Page -- http://php.net/manual/en/function.implode.php
Edit -- https://master.php.net/note/edit/124488
Del: integrated -- https://master.php.net/note/delete/124488/integrated
Del: useless -- https://master.php.net/note/delete/124488/useless
Del: bad code -- https://master.php.net/note/delete/124488/bad+code
Del: spam -- https://master.php.net/note/delete/124488/spam
Del: non-english -- https://master.php.net/note/delete/124488/non-english
Del: in docs -- https://master.php.net/note/delete/124488/in+docs
Del: other reasons-- https://master.php.net/note/delete/124488
Reject -- https://master.php.net/note/reject/124488
Search -- https://master.php.net/manage/user-notes.php