I am trying to get the information from an excel spreadsheet into a PHP array. The problem being that the entries in the spreadsheet include special accented characters such as á and ž etc.
The first thing I did is to export the spreadsheet as a .txt file. I made sure to click on tools --> web options, in order to set the character encoding to UTF-8.
When I opened the .txt file with notepad or notepad++ many (but not all) of the accented characters were replaced with '?'.
for example: Zlatan Ibrahimović ----> Zlatan Ibrahimovi?
However, some of the characters remained unaffected: Carlos Tévez
Furthermore, when I attempted to import the .txt file into a PHP array, the remaining characters turned into question marks aswell!
The following code, is intended to print the first 4 names in the list:
$file = fopen("players/player_names.txt", "r") or exit("Unable to open file!");
$line_array = array();
$x = 0;
while(!feof($file))
{
array_push($line_array, fgets($file));
}
fclose($file);
$name_array = array();
for ($i =1; $i < 4; $i++ )
{
echo $line_array[$i];
echo "<br/>";
}
However, the following is displayed:
Sergio Ag�ero Zlatan Ibrahimovi? Carlos T�vez Luis Su�rez
It appears that the normal question marks '?' are being produced in the transfer from excel to .txt, and the black background question marks of the remaining accented characters '�' are being produced when importing the .txt file to PHP.
I have made sure the character encoding of the PHP file is set to UTF-8 with the following:
header ('Content-type: text/html; charset=utf-8');
Where am I going wrong!?
Thanks for your help in advance :).