note 119236 deleted from function.preg-match-all by cmb
| From: | cmb@php.net | Date: | Tue, 26 Apr 2016 17:00:17 +0000 |
| Subject: | note 119236 deleted from function.preg-match-all by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205343@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
1 .as whois.nic.as #d ds
2 .al whois.ripe.net
1 $regx = "|(\.(?<ext>[A-Z\.a-z]+))( +(?<url>[A-Z\.a-z]+))(
#+(?<comment>.*))?\n?|";
2 preg_match_all($regx,$data,$result,PREG_SET_ORDER);
3 print
"PREG_SET_ORDER<pre>".print_r($result,true)."</pre>";
4 preg_match_all($regx,$data,$result,PREG_OFFSET_CAPTURE);
5 print
"PREG_OFFSET_CAPTURE<pre>".print_r($result,true)."</pre>";
6 preg_match_all($regx,$data,$result,PREG_PATTERN_ORDER);
7 print
"PREG_PATTERN_ORDER<pre>".print_r($result,true)."</pre>";
8 if(isset($result)){
9 foreach($result['ext'] as $key => $item){
10 $line = [];
11 $line['ext'] = $item;
12 if (!empty($result['url'][$key])) $line['url']
= $result['url'][$key];
13 if (!empty($result['comment'][$key]))
$line['comment'] = $result['comment'][$key];
14 $array[$key]=$line;
15 }
16 }
17 print "<pre>".print_r($array,true)."</pre>";
PREG_SET_ORDER
Array(
[0] => Array(
[0] => .as whois.nic.as #d ds [1] => .as
[ext] => as [2] => as [3] => whois.nic.as
[url] => whois.nic.as [4] => whois.nic.as [5] => #d ds
[comment] => d ds [6] => d ds
)
[1] => Array(
[0] => .al whois.ripe.net [1] => .al
[ext] => al [2] => al [3] => whois.ripe.net
[url] => whois.ripe.net [4] => whois.ripe.net
)
)
PREG_OFFSET_CAPTURE
Array(
[0] => Array( [0] => Array( [0] => .as whois.nic.as #d ds [1] => 0 ) [1] =>
Array([0] => .al whois.ripe.net [1] => 24 ))
[1] => Array( [0] => Array( [0] => .as [1] => 0 ) [1] =>
Array([0] => .al [1] => 24 ))
[ext] => Array([0] => Array( [0] => as [1] => 1 ) [1] => Array([0] => al
[1] => 25 ))
[2] => Array( [0] => Array( [0] => as [1] => 1 ) [1] =>
Array([0] => al [1] => 25 ))
[3] => Array( [0] => Array( [0] => whois.nic.as [1] => 3 ) [1] =>
Array([0] => whois.ripe.net [1] => 27 ))
[url] => Array([0] => Array( [0] => whois.nic.as [1] => 4 ) [1] =>
Array([0] => whois.ripe.net [1] => 28 ))
[4] => Array( [0] => Array( [0] => whois.nic.as [1] => 4 ) [1] =>
Array([0] => whois.ripe.net [1] => 28 ))
[5] => Array( [0] => Array( [0] => #d ds [1] => 16 ) [1] =>
)
[comment] => Array( [0] => Array( [0] => d ds [1] => 18 ) [1] =>
)
[6] => Array( [0] => Array( [0] => d ds [1] => 18 ) [1] =>
)
)
PREG_PATTERN_ORDER
Array(
[0] => Array( [0] => .as whois.nic.as #d ds [1] => .al whois.ripe.net )
[1] => Array( [0] => .as [1] => .al )
[ext] => Array( [0] => as [1] => al )
[2] => Array( [0] => as [1] => al )
[3] => Array( [0] => whois.nic.as [1] => whois.ripe.net )
[url] => Array( [0] => whois.nic.as [1] => whois.ripe.net )
[4] => Array( [0] => whois.nic.as [1] => whois.ripe.net )
[5] => Array( [0] => #d ds [1] => )
[comment] => Array([0] => d ds [1] => )
[6] => Array( [0] => d ds [1] => )
)
array
Array(
[0] => Array
(
[ext] => as
[url] => whois.nic.as
[comment] => d ds
)
[1] => Array
(
[ext] => al
[url] => whois.ripe.net
)
)