GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Question: How to replace "�"? (https://gfy.com/showthread.php?t=897611)

Emil 04-03-2009 03:43 AM

PHP Question: How to replace "�"?
 
Anyone know how I can replace this symbol: � within a string? A regular replace doesn't seem to work.

Voodoo 04-03-2009 04:04 AM

delete it and put something else there? :)

quantum-x 04-03-2009 04:06 AM

Industrial strength:
Code:

<?
 $str = 'Your string here';
 $chr = ord('�');
 foreach(str_split($str) as $v) $fS .= ((ord($v) != $chr)?$v:'');

 //Result is in $fS
 var_dump($fS);
?>


nation-x 04-03-2009 04:42 AM

You can also do it on the fly. This is what I had to do... but in my script everything runs through index.php...

Code:

$body = ob_get_contents();
$body = utf8_strip_non_ascii($body);
$body = str_replace('&Atilde;', '', $body);
$body = str_replace(' &Acirc;', '', $body);
$body = str_replace('&Acirc;', '', $body);
ob_end_clean();
print $body;


nation-x 04-03-2009 04:45 AM

Here is an article on it
http://htmlpurifier.org/docs/enduser-utf8.html

quantum-x 04-03-2009 04:54 AM

UTF/Charset manipulation is a right bastard.

Emil 04-03-2009 05:14 AM

thanks for all replies!


All times are GMT -7. The time now is 05:57 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123