The explode()
function has a correlating multibyte-safe function in mb_split()
.
I don't see a correlating function for implode()
. Does this imply that implode is already safe for multibyte strings?
The explode()
function has a correlating multibyte-safe function in mb_split()
.
I don't see a correlating function for implode()
. Does this imply that implode is already safe for multibyte strings?
As long as your delimiter and the strings in the array contain only well-formed multibyte sequences there should not be any issues.
implode
basically is a fancy concatenation operator and I couldn't imagine a scenario where concatenation is not multibyte safe ;)
mb_split(' ', $mbstring)
. Does this constitute a well-formed multibyte sequence? –
Ligulate ' '
would be a single byte space, which is probably not valid in the target charset –
Gooseneck © 2022 - 2024 — McMap. All rights reserved.
split()
in the first place - splitting a string is multi-byte safe by default, no? But that's a different question. – Pozsonyexplode()
with multibyte strings as well, as long as you pass the correct binary representation of the split token. The same therefore applies toimplode()
- the binary sequence passed as the join delimiter will be used literally, so as long as your delimiter is correctly stored, there should be no problems. – Gooseneckexplode()
will not return a string as an array if you try to split on the empty string, which makes explode limited. – Camillecamilo