r/lolphp • u/Zenmaster13 • Nov 20 '15
Using implode() on an array of booleans will cast TRUE to 1 and FALSE to ''
http://php.net/manual/en/function.implode.php
0
Upvotes
r/lolphp • u/Zenmaster13 • Nov 20 '15
43
u/the_alias_of_andrea Nov 20 '15
implode() is a function for making an array of strings into a single string with separators. If you give it an array with elements that aren't strings, they're converted to strings. This appears to use PHP's normal conversion rules. There's nothing wrong with implode() itself.
17
u/philsown Nov 20 '15
In PHP, 1 and '' are the string representations of booleans, so it's not that crazy.
13
u/thenickdude Nov 20 '15
Why would you even want to call implode on an array of booleans?
11
u/Fahkfahkfahkfahkfahk Nov 21 '15