You can enter a Mac range, batch add Mac such as input 11-22-33-44-[aa-ff]-55,1-2-3-34-4-4 will be mass production Mac
- /**
- * Convert to actual multiple ID array based on interval ID
- * @author in Brigitte
- * February 10, 2014 15:29:09
- */
- Class Batchconvertdeviceid {
- public static function convert ($str _str) {
- $str _str = Str_replace (', ', ', ', $str _str);
- $arr _ids = Explode (', ', $str _str);
- $arr _re=array ();
- foreach ($arr _ids as $str _str) {
- $arr _arr = Preg_split ("/\[([^\[\]]+) \]/", $str _str, NULL, Preg_split_delim_capture | Preg_split_no_empty);
- $int _count = count ($arr _arr);
- $arr _data = Array ();
- if ($int _count = = 1) {
- $arr _data = $arr _arr;
- } else {
- for ($i = 0; $i < $int _count; $i + +) {
- if ($i% 2 = = 0) {
- $arr _data = Self::batchlink ($arr _data, Array ($arr _arr[$i]));
- } else {
- Self::batchconvert ($arr _data, $arr _arr[$i]);
- }
- }
- }
- $arr _re = Array_merge ($arr _re, $arr _data);
- }
- return $arr _re;
- }
- private static function Batchconvert (& $arr, $str) {
- $arr _str = Explode ('-', $str);
- $int _start = Base_convert ($arr _str[0], 16, 10);
- $int _end = Base_convert ($arr _str[1], 16, 10);
- $int _min= $int _start< $int _end $int _start: $int _end;
- $int _max= $int _start> $int _end $int _start: $int _end;
- for ($int _min; $int _min <= $int _max; $int _min++) {
- $_arr_str[] = Base_convert ($int _min, 10, 16);
- }
- $arr = Self::batchlink ($arr, $_ARR_STR);
- }
- private static function Batchlink ($arr, $arr _str) {
- $arr _re = Array ();
- if (!empty ($arr)) {
- foreach ($arr as $_V1) {
- foreach ($arr _str as $_V2) {
- $arr _re[] = $_v1. $_V2;
- }
- }
- } else {
- $arr _re = $arr _str;
- }
- return $arr _re;
- }
- }
- $str = "Ab-cd-33-22-aa-[11-13]-[ab-ac]";
- //
- $arr = Batchconvertdeviceid::convert ($STR);
- Echo '
'; - Print_r ($arr);
Copy Code |