Re: Problems converting strings with 0 to integer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux