PHP基础踩坑
- in_array 踩坑
如果写法 in_array('*',$arr); 这种写法是错误的, 如果 $arr=[0]; 该判断就为true了
正确写法 !empty(array_instract(["*"],$arr)); 通过判断交集是否为空来判断更准确, 避免数组中包含 0 时导致字符串in_array都为true的情况 如果写法 in_array('*',$arr); 这种写法是错误的, 如果 $arr=[0]; 该判断就为true了
正确写法 !empty(array_instract(["*"],$arr)); 通过判断交集是否为空来判断更准确, 避免数组中包含 0 时导致字符串in_array都为true的情况