Carlos Jhon manlulu Carlos Jhon manlulu - 1 year ago 100
PHP Question

Array Difference from Database


I have
I have
. I just want to show the value of the difference between those 2 array, I use this code but it give me error:
Array to string conversion
what did I do wrong? or I need more conversion in this function?

$imeiserial = explode(',', $imei);
$imeitransferserial = explode(',', $imeitransfer);


$result= array_diff_assoc($a1,$a2);

Answer Source

That $a1 = array assignment is superfluous. Just leave it:

$a1 = $imeiserial; // no need to put inside an array
$a2 = $imeitransferserial; // once exploded, they are already an array

And using *_assoc flavor doesn't make sense, your keys are numeric, just use array_diff:

$result = array_diff($a1,$a2);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download