How to to read from text file in Arabic characters?

Hi All
I am using this code to read form text file in Arabic characters

<?php
//$file=fopen(d\c1.txt);
$f=fopen("d:\c1.txt","r");
while(! feof($f))
{
$line=fgets($f);
list($id,$name,$amnt,$total)=explode(',',$line);
echo $id."\t".$name;
echo"<br>";
}

?>

but all Arabic character displayed as

��1 '(1'1J'31 E-E/ 9(/'DHDJ
2 '(1'GJE 9(/'D1(
3 '(C1 9(/'DH'39 39J/ -EJ/
4 '(C1 B'3E F9E'F 3D'E
5 '(H (C1 E-E/ F9E'F 'D4(H7J
6 '(H(C1 4G'( G'&D 9(/G E-3F
7 '(H(C1 9DJ 9(/'DDG 9BD'F
8 '

any guide please

You better make sure everything is in utf-8, especially your c1.txt.

To read Arabic characters from a text file in PHP, you need to make sure that the file encoding is set correctly to support Arabic characters. You can use the UTF-8 encoding, which is widely used and supports all Unicode characters, including Arabic.Here’s an updated version of your code that sets the file encoding to UTF-8:

<?php
$file_path = 'd:\c1.txt';
$handle = fopen($file_path, 'r');
if ($handle) {
    while (($line = fgets($handle)) !== false) {
        $line = trim($line);
        $data = explode(',', $line);
        $id = $data[0];
        $name = $data[1];
        $amnt = $data[2];
        $total = $data[3];
        echo "{$id}\t{$name}<br>";
    }
    fclose($handle);
}

In this code, we first set the file path and then open the file in read-only mode using fopen() function. We then loop through each line in the file using the fgets() function and split the line into an array of values using explode() function. We then extract the values from the array and print the first and second values as the ID and name of each record.Note that we also used the trim() function to remove any extra whitespace from the beginning and end of each line, and we used curly braces to include variables in the echo statement.

Thanks
it is working now