which is best array_search or in_array?

前端 未结 7 1024
滥情空心
滥情空心 2020-12-23 20:17

I have a large while loop function, every time it gets loaded for check with current URL name. So I need to know which one is better to check the UR

7条回答
  •  醉梦人生
    2020-12-23 20:51

    If you're only goal is to check if an URL exists in the array I'd go for in_array. Altough the best way is having keys set so you can just search by array key. That way you save alot of looping.

    $searchword = "test";
    echo $array[$searchword];
    

提交回复
热议问题