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