blinks Posted January 29, 2010 Share Posted January 29, 2010 I'm using the following bit of code $diff = array_diff($pids, $pidlist); $diff = array_values($diff); //reindex array to remove empties //output to $discrepancy print_r($diff); exit; Both $pids and $pidlist contain exactly the same value; so I would have expected that value not to appear in $diff - but it is. Both $pids and $pidlist contain a few thousand values, and I've only found this one example which appears in both lists as well as $diff. Can anybody shed any light? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted January 29, 2010 Share Posted January 29, 2010 Both $pids and $pidlist contain exactly the same value Look at array_diff and you'll see the obvious answer why you get nothing. There's no differences if they are the same. Quote Link to comment Share on other sites More sharing options...
blinks Posted January 29, 2010 Author Share Posted January 29, 2010 Sorry, I didn't explain myself very clearly. I do get a lengthy output from array_diff. The issue is that there is one particular array value from among the thousands in each array (it's an integer array) that occurs in both $pid and $pidlist, and therefore shouldn't be in $diff, but is. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2010 Share Posted January 29, 2010 Use var_dump() on the value in each array to see exactly what they are. You will probably find you have some white-space character as part of the value. Quote Link to comment Share on other sites More sharing options...
blinks Posted February 1, 2010 Author Share Posted February 1, 2010 Problem solved! Although I'm still quite puzzled about one aspect of it - print_r of $pids and $pidlist was showing up the duplicated value in both arrays. The var_dump revealed it was present in one, and missing in the other. Perhaps I put the print_r in a difference location??? Anyway, all good now. I traced the issue back to a bug in the parent program. Thanks for your help. 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.