2

I'm using htmlspecialchars to display Greek letters correctly in my html. For that reason I have:

$array = array('sampleGreekString' => 'Ενδιαφερόμαστε για το φορτίο σας')

When I call the function like this:

htmlspecialchars('Ενδιαφερόμαστε για το φορτίο σας')

it works fine and all letters are shown correctly. But when I call it this way:

htmlspecialchars($array['sampleGreekString']);

on the screen are shown only question marks (?). How can I fix this?

Glenn
  • 8,932
  • 2
  • 41
  • 54
Isadora
  • 423
  • 1
  • 5
  • 12
  • I found the real problem. I am using included php file. There is the array with Greek words. When I include it in my view and call htmlspecialchars($array['greekWord']) on the screen are displayed question marks. The problem disappears when the array is defined in the view file. So this is the real problem. Can anybody help with this? – Isadora Sep 10 '15 at 19:19

1 Answers1

1

suppose u have array like this:

$array = array('sampleGreekString' => 'Ενδιαφερόμαστε για το φορτίο σας');

then try the code this way:

function filter(&$value) {
  $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
array_walk_recursive($array, "filter");

The above code applies htmlspecialchars to all the array elements.

Peyman.H
  • 1,819
  • 1
  • 16
  • 26