数组处理,计算ng数量,该如何处理

WBOY
Release: 2016-06-13 12:19:36
Original
1370 people have browsed it

数组处理,计算ng数量

本帖最后由 lazygc520 于 2015-05-12 22:26:04 编辑
<br />array(6) {<br />  [0]=><br />  string(62) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020.csv"<br />  [1]=><br />  string(64) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_1.csv"<br />  [2]=><br />  string(64) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_2.csv"<br />  [3]=><br />  string(64) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_3.csv"<br />  [4]=><br />  string(64) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_4.csv"<br />  [5]=><br />  string(65) "../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_NG.csv"<br />}<br />
Copy after login


已知数组a的形式,如果把7020开头的文件看作一个文件,求得这样的结果:ts407,bed410-500a1,5306,ng对应数量为1.这要怎么求?
------解决思路----------------------
<br />$arr=array(<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_1.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_2.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_3.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_4.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7020_NG.csv",<br />	"../../dat/DIG/TestFunction/TS407/BED410-500A1/5306/NG/7021_NG.csv",//添加测试<br />);<br />foreach($arr as $v){<br />	$tmp=explode('/',$v);<br />	$lastfile=array_pop($tmp);<br />	preg_match('/^(\d+)(\.<br><font color='#FF8000'>------解决思路----------------------</font><br>\_)/',$lastfile,$m);<br />	$arr_file[]=$m[1];<br />}<br />$count=count(array_unique($arr_file));<br />echo $count;//2<br />
Copy after login
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