Jump to content

Problem with my ARRAY_DIFFERENCE script.


cuboidgraphix

Recommended Posts

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.

Link to comment
Share on other sites

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..

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.