Home  >  Article  >  Backend Development  >  数组查找字符串解决办法

数组查找字符串解决办法

WBOY
WBOYOriginal
2016-06-13 12:21:32925browse

数组查找字符串
有个数组,想要查找某个字符串出现的次数。

目前项目中用的是循环foreach遍历,然后计数,有没有更好的方法?
------解决思路----------------------
array_count_values() 返回一个数组,该数组用 input 数组中的值作为键名,该值在 input 数组中出现的次数作为值。 

http://php.net/manual/zh/function.array-count-values.php

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn