$skillsarray = ["php","java","ios","php","php","php","php","java","java","ios"];
$cityarray = ["Chennai","Theni","Theni","Mumbai","Chennai","Theni","Chennai","Hyderabad","Theni","Madurai"];
如果我用array_unique
代替$skillsarray
,得到的结果为
["php","java"、"ios")
如果我用array_unique
代替$cityarray
,得到的结果为
{"0":"奈","1":"那时我","3":"孟买","7":"海德拉巴","9":"马杜赖"}
谁能解释为什么array_unique($cityarray)
产生字典结果?
array_unique从具有id的数组中查找第一个唯一值,这就是$cityarry与$skillarray不同的原因。请检查图像,将容易理解…:)