Comparing PHP strings between two different types of coding

I am trying to match a string that I know with the title of a webpage in php.

I have the following line:

โ„›obinhood

I have a page title that looks like this:

โ„›obinhood

but actually encoded this way if I look at the <title> element:

 &#8475;obinhood 

I am not sure how to compare these two lines. How do I convert &#8475; to โ„› or the other way so that I can make the right comparison?

+4
php unicode decode encode
Jan 07 2018-12-12T00:
source share
2 answers

You can use htmlentites ( http://php.net/manual/en/function.htmlentities.php ) to convert to an entity version.

+1
Jan 07 2018-12-12T00:
source share

Use multibyte string functions:

  • mb_convert_encoding () to convert both versions to something normal (UTF8, internal encoding)
  • mb_strstr () to do a comparison

mb_ * will have an encoding for HTML entities and (most likely), no matter what encoding your string is in.

+1
Jan 07 2018-12-12T00:
source share



All Articles