哪个是最好的array_search或in_array? [英] which is best array_search or in_array?
问题描述
我有一个很大的while循环功能,每次加载时都要使用当前的 URL 名称进行检查.
因此,我需要知道在while循环中检查大型数组中的 URL 名称哪个更好,
in_array()
或array_search()
函数.
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 URL name in large array within the while loop,
in_array()
or array_search()
function.
推荐答案
基于 in_array 和 array_search 主要取决于您对信息的处理方式:如果需要输入,请使用array_search
,如果您只想检查数组中是否存在url,则in_array
就足够了.
Based on the documentation of in_array and array_search, I'd think that it mainly depends on what you want to do with the information: if you need the entry, use array_search
, if you just want to check if the url exists in the array, in_array
should be enough.
这篇关于哪个是最好的array_search或in_array?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!