EchoFool Posted November 1, 2010 Share Posted November 1, 2010 Hey, I am using array diff to find numbers in one array that are not in another array. Yet it returns a value which is in another array which is annoying... my array structure is: Array( [0] => 06 [1] => 11) //this is TEMP Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6 [5] => 11 [6] => 11)//this is VALUES Now my returned difference should be: [0] => 2 [1] => 3 [2] => 5 // all numbers not in TEMP But i get: Array( [0] => 2 [1] => 3 [2] => 5 [3] => 6 [4] => 6)//6 IS in TEMP and should not appear 6 should not appear but it does....any one know why ? This is my code: $Temp = explode('+',$HandValue); $HighCard = array_diff($Values, $Temp); Any ideas? Link to comment https://forums.phpfreaks.com/topic/217496-array-diff-issue/ Share on other sites More sharing options...
Pikachu2000 Posted November 1, 2010 Share Posted November 1, 2010 I suspect your problem lies in this paragraph: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same. [/code] Link to comment https://forums.phpfreaks.com/topic/217496-array-diff-issue/#findComment-1129205 Share on other sites More sharing options...
EchoFool Posted November 1, 2010 Author Share Posted November 1, 2010 I don't follow ? Link to comment https://forums.phpfreaks.com/topic/217496-array-diff-issue/#findComment-1129206 Share on other sites More sharing options...
BlueSkyIS Posted November 1, 2010 Share Posted November 1, 2010 06 !== 6 06 is not identical to 6 06 is not equal to 6 and/or 06 is not of the same type as 6 "06" is not "6" "06" is not 6 Link to comment https://forums.phpfreaks.com/topic/217496-array-diff-issue/#findComment-1129211 Share on other sites More sharing options...
EchoFool Posted November 1, 2010 Author Share Posted November 1, 2010 lol okay i get it now ! Link to comment https://forums.phpfreaks.com/topic/217496-array-diff-issue/#findComment-1129214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.