Last active
July 8, 2020 08:17
-
-
Save Radon8472/b0129da607efc8a2228b4517cfce3f01 to your computer and use it in GitHub Desktop.
php helper functions (to ensure version compatibility)
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 | |
/** | |
* Helper function to avoid problems with the switches argument order of implode since php 7.4.0 | |
* | |
* @see: https://www.php.net/manual/function.implode.php | |
* @see: https://3v4l.org/MZRZA | |
* | |
* @param String $glue | |
* @param array $pieces | |
* | |
* @return string | |
*/ | |
protected static function implode($glue, $pieces) { | |
if(func_num_args() == 1) { | |
$pieces = $glue; | |
$glue = ""; | |
} | |
return (version_compare(PHP_VERSION, '7.4.0') >= 0) | |
? implode($glue,$pieces) | |
: implode($pieces,$glue); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment