I'm echoing into my page some accented words, that sometimes are printed like this:
acatl��n de ju��rez
And after refreshing the page a few times again, it prints them like this:
acatlán de juárez
And the process repeats back and forth. This is not something that should be happening in my application because I'm comparing many things with this words.
I already have utf-8 on my header
<meta charset="UTF-8">
The database collation used: utf8_unicode_ci
The variable causing this errors is assigned like this:
$theString = "acatlan de juarez";
$a = array(
'animal' => array('acatlán de juárez','hów','áre'),
'color' => array('yóu','good','thanks')
);
$b = array(
'animal' => array('acatlan de juarez','how','are'),
'color' => array('you','good','thanks')
);
$theString = str_replace($b['animal'], $a['animal'], $theString);
// $theString now is $theString = "Acatlán de Juárez"
So $theString
variable, when echoed or doing a query, sometimes prints "acatl��n de ju��rez" and some other times prints "acatlán de juárez".
EDIT
I'm starting to receive alot of answers regarding database queries, it actually has nothing to do with the Database, accents are correctly ouputed from the database. Problem is with the variable $theString explained in the code above, it is not printed like it should, with accents.
EDIT 2
I don't know what's happening now, I'm really confused, in this example:
$a = array(
'animal' => array('acatlán de juárez','hów','áre'),
'color' => array('yóu','good','thanks')
);
echo $a['animal'][0];
My code outputs the word "acatlán de juárez" perfectly.
But the I have my array $cities (exactly like my array $a) but with states and cities. Like this:
$cities = array(
'state1' => array('acatlán de juárez','city1','city2'),
'state2' => array('city1','city2','city3')
);
echo $cities['state1'][0];
And now "acatlán de juárez" becomes "acatl��n de ju��rez".... WHY?!?
EDIT 3
Question solved, it was another function bugging the charset format, thank you everyone.