我有我的手真正的奥秘..in_array比较两种不同类型,但返回true
看哪下面的代码行..
if (in_array($_SESSION['enemies'][$i], $clones[$j]->defendAgainst)) {
..
}
其中$ _SESSION [“敌人”] [ $ i]为类似的对象:
object(skinhead)#4 (16)
{
["weapon"]=> object(bowieknife)#5 (2)
{ ["name":protected]=> NULL ["damage":protected]=> NULL }
["name"]=> string(8) "skinhead"
["health"]=>string(3) "100"
["strength"]=> string(2) "10"
["luck"]=> string(1) "2"
["money"]=>string(1) "0"
["exp"]=> string(1) "0"
["rank"]=> string(2) "20"
["points"]=> string(1)"0"
["location_id"]=> NULL
["comboAttack"]=> int(2)
["attackValue"]=> int(15)
["attackType"]=> NULL
["attackMessage"]=> string(198) "Enemy #1 pulls off a 2-hit combo.Enemy #1 slashes at you with a bowie knife.You defend.You lose 8 health.Enemy #1 slashes at you with a bowie knife."
["target1"]=> NULL ["target2"]=> NULL }
和$克隆[$ J] - > defendAgainst是整数数组
现在in_array应评估为false,因为它正在搜索一个int数组中的对象。但相反,它返回真实!怎么会这样?????
请让你的问题可读。 – Starx
它不可读?.... – user2361103
@ user2361103:您的对象全部位于同一行中。 – Blender