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

数组查找字符串解决办法

WBOY
Release: 2016-06-13 12:21:32
Original
972 people have browsed it

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template