Categories :

Multiple words of string replace with str_replace in PHP

<?php
    ## Converting utf8 characters to iso-88591 manually in PHP
    echo “<meta http-equiv=’Content-Type’ content=’text/html; charset=UTF-8′ />”;   
    function str_replace_char(){ 
        $find = array(‘“’, ‘’’, ‘…’, ‘—‘, ‘—‘, ‘‘’, ‘é’, ‘Â’, ‘•’, ‘Ëœ’, ‘‒); // en dash
        $replace = array(‘”‘, ‘’’, ‘…’, ‘—’, ‘–’, ‘‘’, ‘é’, ”, ‘•’, ‘˜’, ‘”‘); // original
        $new_str_content = str_replace( $find,$replace,$str_content);
        return $new_str_content;
    }
   
    $string = “It’s Getting the Best of Me”;
    echo $new_string = str_replace_char($string);
?>

Leave a Reply

Your email address will not be published. Required fields are marked *