Pergunta

$string = 'Single · Female'

I copied it from facebook. In html source its just that dot, how did they type it?
While echoing in php its A with circumflex (Â) concatenated with that same dot.

How can i explode this string with that dot?

Foi útil?

Solução 2

I believe this is an interpunct. It can be used through the HTML entities · or · and in PHP with the unicode value U+00B7.

If you want to echo the unicode character without HTML entities, you can set the character encoding to UTF-8. Splitting is done through explode("·", $textToSplit) given that your PHP file is using UTF-8 as character encoding.

Outras dicas

It is U+00B7 MIDDLE DOT, a character used for many purposes, e.g. as a separator between links, alternatives, or other items.

If your code displays it as ·, then the reason is that the UTF-8 encoded form of U+00B7, namely 0xC2 0xB7, is being misinterpreted as being ISO-8859-1 or Windows-1252 encoded. You should fix this basic problem (instead of trying to deal with some of its symptoms). See UTF-8 all the way through.

Regarding the question “how did they type it?”, we cannot really know, and we need not know. There are zillions of ways to type characters, and anyone can invent a few more. (On my keyboard, I use AltGr Shift X. If I needed to type “·” on a Windows computer with vanilla settings, I would use Alt 0183.)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top