cuboidgraphix Posted April 25, 2008 Share Posted April 25, 2008 Hi again guys, Well i have this array_difference script code that works whenever I have numbers like.... 1 2 3 4 5 6 7 8 9 10 11 etc... In each text file, but it does not seem to work when I have numbers such as, 2800001 2801000 2801010 2801011 2801012 2810123 6600000 6701050 6701052 Can you see if anything is wrong with my code? <?php // Array Difference Script $hlr = @fopen('hlr.txt', 'r'); if ($hlr){ $array1 = explode("\n", fread($hlr, filesize("hlr.txt"))); } $vlr = @fopen('vlr.txt', 'r'); if ($vlr){ $array2 = explode("\n", fread($vlr, filesize("vlr.txt"))); } $diff = array_diff($array1, $array2); foreach ($diff as $value){ echo $value . " "; } ?> Thanks. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 Have you double checked the format of the numbers? Are they all the same format? What exactly is the problem that you are having? Any error messages? Quote Link to comment Share on other sites More sharing options...
cuboidgraphix Posted April 25, 2008 Author Share Posted April 25, 2008 what do you mean the format of the numbers? I just copied and pasted them on a notepad and saved them as text. I don't get any error messages. Just a blank page. I have two files... hlr.txt and vlr.txt when I clean the file and type in... 1 2 3 4 5 6 7 8 9 10 etc.. and in the other file 4 5 6 It works... I get ... 1 2 3 7 8 9 etc. I doesn't work when I paste the 7 digit numbers.. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 25, 2008 Share Posted April 25, 2008 Do you have your error_reporting set to E_ALL? Try var_dump() on your $diff variable. array_diff() isn't supposed to fail, so I'm really sure it's your input variables that are faulty. try checking them with print_r() too. Which version of PHP are you using? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.