On Fri, Jun 18, 2010 at 16:32, Rick Dwyer <rpdw...@earthlink.net> wrote:
> Hello List.
>
> I'm trying to replace the registered (®) symbol from a variable via PHP.
>
> The variable $mystring is set to a MySQL field that contains the value "This
> Is The Registered Symbol ®".
>
> Using the following, I try to replace the symbol, but it persists:
>
> $moditem = str_replace("®","","$mystring");
>
> I tried replacing the symbol in the above syntax with the HTML equivalent
> but no luck.

    Check your database's character encoding.  My check:

<?php
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `example`"));

$mystring = $row['testfield'];

$moditem = str_replace("®","",$mystring);

echo $moditem.PHP_EOL;
?>

    .... worked as expected.  Note that, while it won't make a
difference in your result here, you don't need to use quotes around
your variable in the str_replace() call you showed.  In fact, not only
would it slow down the processes on more-involved or more-popular
sites, but it'll have a larger impact, as you're using double quotes,
which are first evaluated, then passed.  Single quotes would, of
course, literally echo $mystring in your case, but you get the point.
Just a quick tip.

-- 
URGENT:
THROUGH FRIDAY, 18 JUNE ONLY: $100 OFF
YOUR FIRST MONTH, FREE CPANEL FOR LIFE
ON ANY NEW DEDICATED SERVER.  NO LIMIT!
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to