php - array_diff_assoc() is considering 1 === "1" -


i running code php.net example

<?php $array1 = array(0, 1, 2); $array2 = array("00", "01", "2"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> 

output of getting :

array (     [0] => 0     [1] => 1 ) 

php.net says : 2 values key => value pairs considered equal only if (string) $elem1 === (string) $elem2 .

whereas in example considers 2 === "2".

how happening ? please explain ?

might case

if $ele1 casting integer string i.e. 2 "2", why comparing === operator. there might 2 == "2" better option , don't need cast string. please correct me, if wrong ?

if $ele1 casting integer string i.e. 2 "2", why comparing === operator. there might 2 == "2" better option , don't need cast string. please correct me, if wrong ?
it's way implemented.
if want comparision function use array_diff_uassoc()


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -