Re: Problems converting strings with 0 to integer
| From: | robert mena | Date: | Thu, 04 Nov 2010 15:14:44 +0000 |
| Subject: | Re: Problems converting strings with 0 to integer | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-309297@lists.php.net to get a copy of this message | ||
Hi,
The core of the code is simply
$fp = fopen('file.tab', 'rb');
while(!feof($fp))
{
$line = fgets($fp);
$data = explode("\t", $line);
...
}
So I try to manipulate the $data[X]. For example $data[0] is supposed to be
numeric so I $n = (int) $data[0]
One other thing if the second column should contain a string. If I check
the string visually it is correct but a if( $data[1] == 'stringX') is false
even if in the file I can see this (and print those two)
I even did a md5 of both and they are different.
I seems to be an encoding issue. Is it safe to use explode with utf8
strings?
I even tried this code but no match found (jst to replace the explode)
$str = "abc 文字化け efg";
$results = array();
preg_match_all("/\t/u", $str, $results);
var_dump($results[0]);
(I am sending this again without the reply because the first email was
refused for some reason)