note 124488 deleted from function.implode by cmb

From: Date: Sat, 07 Dec 2019 12:43:50 +0000
Subject: note 124488 deleted from function.implode by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213414@lists.php.net to get a copy of this message
Note Submitter: radon8472 ---- 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"

« previous php.notes (#213414) next »