1.2.551. Implode One Arg¶
implode() may be called with one arg. It is recommended to avoid it.
Using two arguments makes it less surprising to new comers, and consistent with explode() syntax.
<?php
$array = range('a', 'c');
// empty string is the glue
print implode('', $array);
// only the array : PHP uses the empty string as glue.
// Avoid this
print implode($array);
?>
See also implode.
1.2.551.1. Suggestions¶
Add an empty string as first argument
1.2.551.2. Specs¶
Short name |
Php/ImplodeOneArg |
Rulesets |
All, Changed Behavior, PHP recommendations, Suggestions, php-cs-fixable |
Exakat since |
1.7.7 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |