I have a lot Persian text and I want explode it, I store my text in a file.txt
. (So i have a file.text containing Persian text). Now my problem is charset. When i save the text into file.text
, it give me a error:
This file contains characters in Unicode format which will be lost if you save this file as a ANSI encoded text file. To keep the Unicode information, click cancel below and then select one of the Unicode options from the Encoding drop down list. Continue?
I continue. Now when I open file.text
all characters are fine, and when explode it, all characters crash.
Note: when I put text in a php variable, all thing is fine, in fact my problem is with file.text.
What should I do ?
My code: (for explode)
$text=file_get_contents('file.txt');
$var = explode("
", $text);
foreach ($var as $sentence) {
echo $sentence.'<br>'; // or save into databse
}