I have a php script, in which I read an $array
and fwrite
the desired value to a .txt
file.
PHP Code:
<?php
$array = unserialize(file_get_contents('rawdata.txt'));
$handle = fopen("ean.txt", "a");
foreach ( $array as $key=>$value ) {
if ( $key != 0 ) {
echo $value[21]."<br>";
}
fwrite($handle, "$value[21]\n");
}
?>
Note: when I print_r()
the $array
all values from the .txt
file are displayed correctly.
But when I try to fwrite()
the array in another .txt
file I get this Symbol on the position that I should get the \n
.
Symbol: ਠ
Questions: Why is this happening? What should I look for to try and troubleshoot this issue?
Thanks in advance for your time and effort!
My Answer:
it depend on the context in which it is being used?
Rate this post
4 of 5 based on 1553 votesComments