Jefsama Jefsama - 1 year ago 156
PHP Question

Php array_intersect output

i'm having trouble with how array works.

$a = array("24","33","12");
$b = array("24","12");

$c = array_intersect($a,$b);

echo json_encode($c);

// {"0":"24","2":"12"}

I expect the output to be like this:

// ["24","12"]

How can i achieve that output?

Answer Source
echo json_encode(array_values($c));


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download