I have a CSV file which contains words in english followed by Hindi words. I am trying to read the CSV file and do some further processing with it. The csv file looks like so:
Vice President-1 ????? ?????? ????
Vice President-2 ? ? ?
Vice President-3 ? ? ?
Secretary ? ? ?
How to read this file in php with Hindi words i also insert that word in database , and retrive
move_uploaded_file($_FILES['file']['tmp_name'],$target_path);
$file = fopen("$target_path", "r");
while (($data = fgetcsv($file, 8000, ",")) !== FALSE)
{
}
I had a similar problem with hebrew and found out getcsv() functions don't work well with non english UTF-8.
Here is my solution (parsing csv manually):
$data = 'some csv string';
$data_arr = preg_split("/((?
)|(
?))/", $data);
while ($line = array_shift($data_arr))
{
$row = array();
$line = preg_match_all('/"[^"]+"|[^,]+/', $line, $matches);
$line = $matches[0];
//your code here
}