reference/pcre/functions/preg-match-all.xml
6712ff65342f3c87d03f90fa420782d37b9be58c
...
...
@@ -9,11 +9,11 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>int</type><methodname>preg_match_all</methodname>
12
+
<type class="union"><type>int</type><type>false</type></type><methodname>preg_match_all</methodname>
13
13
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
14
14
<methodparam><type>string</type><parameter>subject</parameter></methodparam>
15
-
<methodparam choice="opt"><type>array</type><parameter role="reference">matches</parameter></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>PREG_PATTERN_ORDER</constant></initializer></methodparam>
15
+
<methodparam choice="opt"><type>array</type><parameter role="reference">matches</parameter><initializer>&null;</initializer></methodparam>
16
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
17
17
<methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
18
18
</methodsynopsis>
19
19
<para>
...
...
@@ -94,8 +94,8 @@ example: , this is a test
94
94
]]>
95
95
</screen>
96
96
<para>
97
-
So, <varname>$out[0]</varname> contains array of strings that matched full pattern,
98
-
and <varname>$out[1]</varname> contains array of strings enclosed by tags.
97
+
So, <varname>$out[0]</varname> contains an array of strings that matched the full pattern,
98
+
and <varname>$out[1]</varname> contains an array of strings enclosed by tags.
99
99
</para>
100
100
</informalexample>
101
101
</para>
...
...
@@ -169,7 +169,7 @@ echo $out[1][0] . ", " . $out[1][1] . "\n";
169
169
<listitem>
170
170
<para>
171
171
If this flag is passed, for every occurring match the appendant string
172
-
offset will also be returned. Note that this changes the value of
172
+
offset (in bytes) will also be returned. Note that this changes the value of
173
173
<parameter>matches</parameter> into an array of arrays where every element is an
174
174
array consisting of the matched string at offset <literal>0</literal>
175
175
and its string offset into <parameter>subject</parameter> at offset
...
...
@@ -235,6 +235,15 @@ Array
235
235
</para>
236
236
</listitem>
237
237
</varlistentry>
238
+
<varlistentry>
239
+
<term><constant>PREG_UNMATCHED_AS_NULL</constant></term>
240
+
<listitem>
241
+
<para>
242
+
If this flag is passed, unmatched subpatterns are reported as &null;;
243
+
otherwise they are reported as an empty <type>string</type>.
244
+
</para>
245
+
</listitem>
246
+
</varlistentry>
238
247
</variablelist>
239
248
</para>
240
249
<para>
...
...
@@ -254,7 +263,7 @@ Array
254
263
<note>
255
264
<para>
256
265
Using <parameter>offset</parameter> is not equivalent to passing
257
-
<literal>substr($subject, $offset)</literal> to
266
+
<code>substr($subject, $offset)</code> to
258
267
<function>preg_match_all</function> in place of the subject string,
259
268
because <parameter>pattern</parameter> can contain assertions such as
260
269
<emphasis>^</emphasis>, <emphasis>$</emphasis> or
...
...
@@ -271,11 +280,15 @@ Array
271
280
<refsect1 role="returnvalues">
272
281
&reftitle.returnvalues;
273
282
<para>
274
-
Returns the number of full pattern matches (which might be zero),
275
-
or &false; if an error occurred.
283
+
Returns the number of full pattern matches (which might be zero),&return.falseforfailure;.
276
284
</para>
277
285
</refsect1>
278
286

287
+
<refsect1 role="errors">
288
+
&reftitle.errors;
289
+
&pcre.pattern.warning;
290
+
</refsect1>
291
+

279
292
<refsect1 role="changelog">
280
293
&reftitle.changelog;
281
294
<para>
...
...
@@ -289,27 +302,10 @@ Array
289
302
</thead>
290
303
<tbody>
291
304
<row>
292
-
<entry>5.4.0</entry>
305
+
<entry>7.2.0</entry>
293
306
<entry>
294
-
The <parameter>matches</parameter> parameter became optional.
295
-
</entry>
296
-
</row>
297
-
<row>
298
-
<entry>5.3.6</entry>
299
-
<entry>
300
-
Returns &false; if <parameter>offset</parameter>
301
-
is higher than
302
-
<parameter>subject</parameter> length.
303
-
</entry>
304
-
</row>
305
-
<row>
306
-
<entry>5.2.2</entry>
307
-
<entry>
308
-
Named subpatterns now accept the
309
-
syntax <literal>(?&lt;name&gt;)</literal>
310
-
and <literal>(?'name')</literal> as well
311
-
as <literal>(?P&lt;name&gt;)</literal>. Previous versions
312
-
accepted only <literal>(?P&lt;name&gt;)</literal>.
307
+
The <constant>PREG_UNMATCHED_AS_NULL</constant> is now supported for the
308
+
<parameter>$flags</parameter> parameter.
313
309
</entry>
314
310
</row>
315
311
</tbody>
...
...
@@ -390,8 +386,7 @@ FOO;
390
386

391
387
preg_match_all('/(?P<name>\w+): (?P<digit>\d+)/', $str, $matches);
392
388

393
-
/* This also works in PHP 5.2.2 (PCRE 7.0) and later, however
394
-
* the above form is recommended for backwards compatibility */
389
+
/* Alternative */
395
390
// preg_match_all('/(?<name>\w+): (?<digit>\d+)/', $str, $matches);
396
391

397
392
print_r($matches);
...
...
@@ -461,7 +456,6 @@ Array
461
456
</refsect1>
462
457

463
458
</refentry>
464
-

465
459
<!-- Keep this comment at the end of the file
466
460
Local variables:
467
461
mode: sgml
468
462