downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/fr/function.preg-grep.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.pcre.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'fr',
  ),
 
'this' =>
  array (
   
0 => 'function.preg-grep.php',
   
1 => 'preg_grep',
  ),
 
'up' =>
  array (
   
0 => 'ref.pcre.php',
   
1 => 'Fonctions PCRE',
  ),
 
'prev' =>
  array (
   
0 => 'function.preg-filter.php',
   
1 => 'preg_filter',
  ),
 
'next' =>
  array (
   
0 => 'function.preg-last-error.php',
   
1 => 'preg_last_error',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.preg-grep" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">preg_grep</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">preg_grep</span> &mdash; <span class="dc-title">Retourne un tableau avec les résultats de la recherche</span></p>

 </div>

 <a name="function.preg-grep.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><b>preg_grep</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$pattern</tt></span>
   , <span class="methodparam"><span class="type">array</span> <tt class="parameter">$input</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$flags</tt><span class="initializer">= 0</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   <b>preg_grep()</b> retourne un <a href="language.types.array.php" class="link">tableau</a> qui contient
   les éléments de <i><tt class="parameter">input</tt></i>

   qui satisfont le masque <i><tt class="parameter">pattern</tt></i>
.
  </p>
 </div>


 <a name="function.preg-grep.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">pattern</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Le motif à chercher, sous la forme d&#039;une <a href="language.types.string.php" class="link">chaîne de caractères</a>.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">input</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Le tableau d&#039;entrée.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">flags</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Si cette option vaut <b><tt class="constant">PREG_GREP_INVERT</tt></b>,
       cette fonction retourne les éléments du tableau
       <i><tt class="parameter">input</tt></i>
 qui ne correspondent
       <em class="emphasis">pas</em> au motif
       <i><tt class="parameter">pattern</tt></i>
.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.preg-grep.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne un <a href="language.types.array.php" class="link">tableau</a> indexé, en utilisant les clé du
   tableau <i><tt class="parameter">input</tt></i>
 d&#039;entrée.
  </p>
 </div>


 <a name="function.preg-grep.changelog"></a><div class="refsect1 changelog">
  <h3 class="title">Historique</h3>
  <p class="para">
   </p><table class="doctable informaltable">
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">4.2.0</td>
       <td align="left">
        Le paramètre <i><tt class="parameter">flags</tt></i>
 a été ajouté.
       </td>
      </tr>

      <tr valign="middle">
       <td align="left">4.0.4</td>
       <td align="left">
        <p class="para">
         Depuis cette version, le tableau retourné est indexé
         en utilisant les clés issues du tableau <i><tt class="parameter">input</tt></i>
.
        </p>
        <p class="para">
         Pour obtenir l&#039;ancien comportement, utilisez la fonction
         <a href="function.array-values.php" class="function">array_values()</a> sur le tableau retourné
         afin de réindexer les valeurs.
        </p>
       </td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div>


 <a name="function.preg-grep.examples"></a><div class="refsect1 examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Exemple #1 Exemple avec <b>preg_grep()</b></b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Recherche&nbsp;les&nbsp;nombres&nbsp;à&nbsp;virgule&nbsp;flottante&nbsp;dans&nbsp;le&nbsp;tableau<br /></span><span style="color: #0000BB">$fl_array&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">preg_grep</span><span style="color: #007700">(</span><span style="color: #DD0000">"/^(\d+)?\.\d+$/"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites