note 119236 added to function.preg-match-all
| From: | Anonymous | Date: | Sun, 24 Apr 2016 19:21:39 +0000 |
| Subject: | note 119236 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205314@lists.php.net to get a copy of this message | ||
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
)
)
----
Server IP: 72.52.91.14
Probable Submitter: 87.65.80.135
----
Manual Page -- http://php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/119236
Del: integrated -- https://master.php.net/note/delete/119236/integrated
Del: useless -- https://master.php.net/note/delete/119236/useless
Del: bad code -- https://master.php.net/note/delete/119236/bad+code
Del: spam -- https://master.php.net/note/delete/119236/spam
Del: non-english -- https://master.php.net/note/delete/119236/non-english
Del: in docs -- https://master.php.net/note/delete/119236/in+docs
Del: other reasons-- https://master.php.net/note/delete/119236
Reject -- https://master.php.net/note/reject/119236
Search -- https://master.php.net/manage/user-notes.php