@@ 162-182 (lines=21) @@ | ||
159 | if (empty($str)) |
|
160 | $str = &$this->mRs; |
|
161 | $i = preg_match_all($preg, $str, $ar, PREG_SET_ORDER); |
|
162 | if (0 == $i || false === $i) |
|
163 | // Got none match or Got error |
|
164 | $ar = ''; |
|
165 | elseif (1 == $i) |
|
166 | { |
|
167 | // Got 1 match, return as string or array(2 value in 1 match) |
|
168 | $ar = $ar[0]; |
|
169 | array_shift($ar); |
|
170 | if (1 == count($ar)) |
|
171 | $ar = $ar[0]; |
|
172 | } |
|
173 | else |
|
174 | { |
|
175 | // Got more than 1 match return array contains string or sub-array |
|
176 | foreach ($ar as &$row) |
|
177 | { |
|
178 | array_shift($row); |
|
179 | if (1 == count($row)) |
|
180 | $row = $row[0]; |
|
181 | } |
|
182 | } |
|
183 | return $ar; |
|
184 | } // end of func Match |
|
185 |
@@ 29-49 (lines=21) @@ | ||
26 | function RegexMatch($preg, $str = '', $csrts = true) { |
|
27 | if (empty($preg) || empty($str)) return ''; |
|
28 | $i = preg_match_all($preg, $str, $ar, PREG_SET_ORDER); |
|
29 | if (0 == $i || false === $i) |
|
30 | // Got none match or Got error |
|
31 | $ar = ''; |
|
32 | elseif (1 == $i) |
|
33 | { |
|
34 | // Got 1 match, return as string or array(2 value in 1 match) |
|
35 | $ar = $ar[0]; |
|
36 | array_shift($ar); |
|
37 | if (1 == count($ar) && true == $csrts) |
|
38 | $ar = $ar[0]; |
|
39 | } |
|
40 | else |
|
41 | { |
|
42 | // Got more than 1 match return array contains string or sub-array |
|
43 | foreach ($ar as &$row) |
|
44 | { |
|
45 | array_shift($row); |
|
46 | if (1 == count($row)) |
|
47 | $row = $row[0]; |
|
48 | } |
|
49 | } |
|
50 | return $ar; |
|
51 | } // end of func RegexMatch |
|
52 | ?> |