从字符串中删除€符号[重复]

This question already has an answer here:

I use this code to display price inside a Magento shop:

<?php

    $myPrice = $_coreHelper->formatPrice($_price + $_weeeTaxAmount, false);
    $zeros = substr($myPrice, -2);

    if(strval($zeros) == "00") {
        $myPrice = substr($myPrice, 0, -2);
        $myPrice = $myPrice . '-';
    }

    echo '<span class="price">'.$myPrice.'</span>';

?>

But I also want to remove the € sign from this string.

How can I fix that?

</div>

str_replace($search,$replace,$string) might be the function you are looking for.

take a look at this line of code:

$myPrice = str_replace("€","",$myPrice);

this will search the string for € and replace it with an empty string, which means it removes the €.

refer to the php documentation for further information. i.e. you can also use arrays for $search and $replace (examples in the php doc)

full example:

<?php 
$myPrice = $_coreHelper->formatPrice($_price + $_weeeTaxAmount, false);
$zeros = substr($myPrice, -2);
if(strval($zeros) == "00") { $myPrice = substr($myPrice, 0, -2);
$myPrice = $myPrice . '-'; }

$myPrice = str_replace("€","",$myPrice);
//or if the € is htmlencoded
$myPrice = str_replace("&euro;","",$myPrice);

echo '<span class="price">'.$myPrice.'</span>'; 
?>

Use php str_replace :-

str_replace("€","",$yourstring);

This function is binary-safe

str_replace(find,replace,string,count)