Array processing to calculate the number of NG
This post was last edited by lazygc520 on 2015-05-12 22:26:04
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 "
}
Known quantity the form of group A, if you think of a file starting with 7020 as a file, the result is: Ts407,bed410-500a1,5306,ng corresponds to a number of 1. How can I ask for it?
------to solve the idea----------------------
$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 ",//Add test
);
foreach ($arr as $v) {
$tmp =explode ('/', $v);
$lastfile =array_pop ($tmp);
Preg_match ('/^ (\d+) (\.
------to solve the idea----------------------
\_)/', $lastfile, $m);
$arr _file[]= $m [1];
}
$count =count (Array_unique ($arr _file));
echo $count;//2