Array processing, calculating the number of NG, how to handle

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.