我使用的是PHPin_array()函数.
下面的PHP代码示例:
<?php
$basket = [ 'apple', 'pear', 'banana' ];
if (!in_array('raspberry', $basket)) {
$basket[] = 'raspberry';
}
var_dump($basket);
您是否建议指定strict = true
参数?
I think it is not necessary because it is ensured that there are only strings in the array (no null, nor something of other type).
Also the 1st argument of the function is ensured to be a string.
Because I am unsure and would like to know if it is correct to specify strict = true
only for cases when there objects in the array of various types and the argument might be of a different type.
期待着从这里的社区听到更多的消息.