哪个是最好的 array_search 或 in_array? [英] which is best array_search or in_array?

查看:27
本文介绍了哪个是最好的 array_search 或 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_arrayarray_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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆