I have a strange problem and I am not sure how to resolve it. I would like to get the first character of a Text field I get from a Database. With this character, I would apply a CSS style to make it big.
If you try this following code, you will understand what is my problem:
<?php
$str_en = "I am a sentence.";
echo $str_en[0];
echo "<br /><br />";
$str_fr = "À tous les jours je fais du PHP.";
echo $str_fr[0];
echo "<br /><br />";
$str_fr = "Étais-tu ici?";
echo $str_fr[0];
?>
The code Above will output:
I
Ã
Ã
It seems like that a French character is using more than one bytes in a string. The problem is that not all my sentence start with a French character. Anyone have an idea how I could have a function that convert this:
<?php
$str_fr = "Étais-tu ici?";
?>
To this
$str_fr = "<span class='firstletter'>É</span>tais-tu ici?";
Or perhaps there is a better way with CSS3 to do this.