哪个是最好的 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屋!