Hey I am trying to read Hebrew chars from PhpMyAdmin table and it just comes out as a mess, on the table it look's fine and written in Hebrew but when I move it to php using SELECT the output is like this:
05deu05d9u05e8u05d4u05deu05d9u05e8u05d4u05deu05d9u05e8u05d4
I tried encoding the php page to utf-8 and it didn't helped my table is enconde as
utf8_general_ci
I don't know what to do..
my php code is:
$sql = "select * from sample;";
$conn = mysqli_connect($host,$username,$password,$db);
if (!$conn->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $conn->error);
} else {
printf("Current character set: %s\n", $conn->character_set_name());
}
$result = mysqli_query($conn,$sql);
$response = array();
while($row = mysqli_fetch_array($result))
{
array_push($response,array($row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6]));
}
$str = json_encode(array($response));
$str = clean($str);
echo $str;
mysqli_close($conn);
function clean($string) {
$string = str_replace(' ', ' ', $string);
$string = preg_replace('/[^a-zA-Z0-9,: -]/', '', $string);
return preg_replace('/-+/', '-', $string);
}
?>