I have a really long html string which consists of Greek and English text with html tags wrapped around most of the words. I have been successfully using the function below in the past to remove Greek accents from text so that it capitalizes beautifully.
However in this text after some characters, replacement stops from happening and text returns with accents. I have tried some other functions as well that I found around the web but with no luck.
Any help?
The function that I'm using is:
public static function stripAccents($str) {
$a = array('ά','έ','ή','ί','ύ','ό','ώ','ς','Ά','Έ','Ή','Ί','Ύ','Ό','Ώ');
$b = array('α','ε','η','ι','υ','ο','ω','Σ','Α','Ε','Η','Ι','Υ','Ο','Ω');
return str_replace($a, $b, $str);
}
And a sample of the text is:
<div class="menu-page">
<h3>DESSERTS / ΕΠΙΔΟΡΠΙΑ</h3>
<h4>GOAT CHEESE ICE CREAM (N)</h4>
<p class="price">€7,50</p>
<p>Παγωτό από κατσικίσιο τυρί με μαρμελάδα ντομάταΣ & κρέμα λεμονιού</p>
<p>With tomato marmalade & lemon cream</p>
<div class="clearfix"></div>
<h4>MOCHA A LA PALAIA</h4>
<p class="price">€8,50</p>
<p>Παγωτό καφέ, βανίλιαΣ & Ιταλική μαρέγκα</p>
<p>Coffee and vanilla ice cream & Italian meringue<p>
<div class="clearfix"></div>
<h4>THE TRAIL OF CHOCOLATE (N)</h4>
<p class="price">€9,50</p>
<p>Εύπλαστη σοκολάτα & υφέΣ από πορτοκάλι</p>
<p>Chocolate and different orange textures</p>
<div class="clearfix"></div>
<h4>CANNOLO</h4>
<p class="price">€9,50</p>
<p>Ελαφρύ μπισκότο γεμιστό με σοκολάτα και passion fruit sorbet</p>
<p>Chocolate cannolo with passion fruit sorbet</p>
<div class="clearfix"></div>
<h4>AUBERGINE TIRAMISU</h4>
<p class="price">€12,00</p>
<p>Με μουΣ μελιτζαναΣ</p>
<p>With eggplant mousse</p>
</div>
It doesn't work, because they are different characters. If you look for example at ό.
In your function it is:
CE BF CC 81 //ό
But in your string you have:
CF 8C //ό
So make sure you use the same characters in your string and function
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