4
I have 2 arrays that come from 2 different banks, one comes from sql server other mysql.
The Mysl query returns like this..
array (size=6)
0 => string 'ultimoteste3' (length=12)
1 => string 'ultimoteste3' (length=12)
2 => string 'Rodrigues' (length=9)
3 => string '[email protected]' (length=24)
4 => string '2' (length=1)
5 => string 'Teste Curso' (length=11)
Already the query of sql server that is a Procedure returns like this:
array (size=16)
'username' => string 'username' (length=8)
0 => string 'username' (length=8)
'firstname' => string 'firstname' (length=9)
1 => string 'firstname' (length=9)
'lastname' => string 'lastname' (length=8)
2 => string 'lastname' (length=8)
'email' => string 'email' (length=5)
3 => string 'email' (length=5)
'lang' => string 'lang' (length=4)
4 => string 'lang' (length=4)
'course1' => string 'course1' (length=7)
5 => string 'course1' (length=7)
'type1' => string 'type1' (length=5)
6 => string 'type1' (length=5)
'auth' => string 'auth' (length=4)
7 => string 'auth' (length=4)
How much I use
print_r(array_diff($lista1, $lista2));
the result comes like this...
Array ( )
I need to go through the two arrays and discover the users that are in one and not in the other, bring the difference between the arrays...
to keep the values of each one I did so
mysql = $lista1 = mysqli_fetch_all($result);
sqlServer = $lista2 = $consulta->fetchAll(); (pq uso PDO);
What is your question? Specify better, make it clear what you want help with.
– Wallace Maxters
How you store the result in $lista1 and $Lista2?
– Diego
How do you expect it to return?
– Guilherme Lopes
I hope that return different users between the arrays, to form another list of users, so I manipulate...
– Yuri Rodrigues
This second array ($Lista2) has a confusing structure, because it has a different index than $lista1?
– Walker Leite
Wow! Do you want to know if the user is unique?! It looks like he’s going down a tough road. But I get it, it’s two different banks.
– Wallace Maxters
i realized the test on ideone only with arrays and the result was "normal", it shows all array 1 because no data of it contains in array 2.
– RFL
Make sure that the PHP version is higher than 4.0.4, according to the documentation the array_diff function has problems in the old versions.
– Walker Leite
Remember that the diff array displays the array values of the first parameter that are NOT in the second parameter. Not the other way around.
– Walker Leite
Make the following trade
var_dump()
forvar_export($var, true);
ai you put the ready estruta of the test arrays in the question.– rray