mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added basic preg_filter() docs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@278476 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
b23163023b
commit
66baab5c9b
1 changed files with 168 additions and 0 deletions
168
reference/pcre/functions/preg-filter.xml
Normal file
168
reference/pcre/functions/preg-filter.xml
Normal file
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry xml:id="function.preg-filter" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>preg_filter</refname>
|
||||
<refpurpose>Perform a regular expression search and replace</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>preg_filter</methodname>
|
||||
<methodparam><type>mixed</type><parameter>pattern</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>replacement</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>subject</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer>-1</initializer></methodparam>
|
||||
<methodparam choice="opt"><type>int</type><parameter role="reference">count</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>preg_filter</function> is identical to <function>preg_replace</function>
|
||||
except it only returns the matches. For details about how this function works,
|
||||
read the <function>preg_replace</function> documentation.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>pattern</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>replacement</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>subject</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>limit</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>count</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns an <type>array</type> if the <parameter>subject</parameter>
|
||||
parameter is an <type>array</type>, or a <type>string</type> otherwise.
|
||||
</para>
|
||||
<para>
|
||||
If matches are found, the new <parameter>subject</parameter> will
|
||||
be returned, otherwise <parameter>subject</parameter> will be
|
||||
returned unchanged or &null; if an error occurred.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>
|
||||
Example comparing <function>preg_filter</function>
|
||||
with <function>preg_replace</function>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$subject = array('1', 'a', '2', 'b', '3', 'A', 'B', '4');
|
||||
$pattern = array('/\d/', '/[a-z]/', '/[1a]/');
|
||||
$replace = array('A:$0', 'B:$0', 'C:$0');
|
||||
|
||||
echo "preg_filter returns\n";
|
||||
print_r(preg_filter($pattern, $replace, $subject));
|
||||
|
||||
echo "preg_replace returns\n";
|
||||
print_r(preg_replace($pattern, $replace, $subject));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
preg_filter returns
|
||||
Array
|
||||
(
|
||||
[0] => A:C:1
|
||||
[1] => B:C:a
|
||||
[2] => A:2
|
||||
[3] => B:b
|
||||
[4] => A:3
|
||||
[7] => A:4
|
||||
)
|
||||
preg_replace returns
|
||||
Array
|
||||
(
|
||||
[0] => A:C:1
|
||||
[1] => B:C:a
|
||||
[2] => A:2
|
||||
[3] => B:b
|
||||
[4] => A:3
|
||||
[5] => A
|
||||
[6] => B
|
||||
[7] => A:4
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><function>preg_replace</function></member>
|
||||
<member><function>preg_replace_callback</function></member>
|
||||
<member><function>preg_match</function></member>
|
||||
<member><function>preg_split</function></member>
|
||||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:1
|
||||
sgml-indent-data:t
|
||||
indent-tabs-mode:nil
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:"../../../../manual.ced"
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||||
vim: et tw=78 syn=sgml
|
||||
vi: ts=1 sw=1
|
||||
-->
|
Loading…
Reference in a new issue