I am having difficulty to match two text strings. One contains some hidden characters from a text string.
I have a text string: "PR & Communications" stored on an SQL database. When pulled from there, into $database_version
, var_dump($database_version)
reveals the string to have 19 bytes.
I have scraped (with permission) from a website, some text into a variable, $web_version
. Ostensibly the string is "PR & Communications" but it does not match the database version, i.e if($database_version == $web_version)
is NOT true.
var_dump()
reveals $web_version
to have 23 bytes. trim()
has no effect, nor does strip_tags()
but preg_replace( '/[^\PC\s]/u', $web_version )
removes something because afterwards string_var($web_version)
reveals the string to comprise 14 bytes only. It has clearly removed something, possibly too much, as the string still does not match with $database_version
.
Any ideas how to:
PS I don't know how to view the variable in hexadecimal code
$v = preg_replace('/\s+|[[:^print:]]/', '', $string);
trim() removes only " \t\n\r\0\x0B" (see docs), so use snippet above to remove non-printed characters from string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With