<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.strrchr.php',
    1 => 'strrchr',
    2 => 'Find the last occurrence of a character in a string',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.strpos.php',
    1 => 'strpos',
  ),
  'next' => 
  array (
    0 => 'function.strrev.php',
    1 => 'strrev',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/strrchr.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strrchr" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strrchr</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strrchr</span> &mdash; <span class="dc-title">Find the last occurrence of a character in a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.strrchr-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>strrchr</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$haystack</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$needle</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$before_needle</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   This function returns the portion of <code class="parameter">haystack</code> which
   starts at the last occurrence of <code class="parameter">needle</code> and goes
   until the end of <code class="parameter">haystack</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strrchr-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">haystack</code></dt>
     <dd>
      <p class="para">
       The string to search in
      </p>
     </dd>
    
    
     <dt><code class="parameter">needle</code></dt>
     <dd>
      <p class="para">
       If <code class="parameter">needle</code> contains more than one character,
       only the first is used. This behavior is different from that of
       <span class="function"><a href="function.strstr.php" class="function">strstr()</a></span>.
      </p>
      
 <p class="para">
  До версії PHP 8.0.0, якщо параметр <code class="parameter">needle</code> не є рядком,
  він перетворюється на ціле число і розглядається як код символу. Ця поведінка
  є застарілою, починаючи з PHP 7.3.0. Вкрай не рекомендується на неї
  покладатися. Залежно від потрібної поведінки, параметр
  <code class="parameter">needle</code> необхідно привести до рядкового типу або
  обробити функцією <span class="function"><a href="function.chr.php" class="function">chr()</a></span>.
 </p>

     </dd>
    
    
     <dt><code class="parameter">before_needle</code></dt>
     <dd>
      <p class="para">
       If <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, <span class="function"><strong>strrchr()</strong></span>
       returns the part of the <code class="parameter">haystack</code> before the
       last occurrence of the <code class="parameter">needle</code> (excluding the needle).
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strrchr-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   This function returns the portion of string, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if
   <code class="parameter">needle</code> is not found.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.strrchr-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       The <code class="parameter">before_needle</code> parameter was added.
      </td>
     </tr>

     <tr>
 <td>8.0.0</td>
 <td>
  Тепер параметр <code class="parameter">needle</code> може бути порожнім рядком.
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Passing an <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> as <code class="parameter">needle</code> is no longer supported.
      </td>
     </tr>

     <tr>
      <td>7.3.0</td>
      <td>
       Passing an <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> as <code class="parameter">needle</code> has been deprecated.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.strrchr-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>strrchr()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$ext </span><span style="color: #007700">= </span><span style="color: #0000BB">strrchr</span><span style="color: #007700">(</span><span style="color: #DD0000">'somefile.txt'</span><span style="color: #007700">, </span><span style="color: #DD0000">'.'</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"file extension: </span><span style="color: #0000BB">$ext</span><span style="color: #DD0000"> \n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$ext </span><span style="color: #007700">= </span><span style="color: #0000BB">$ext </span><span style="color: #007700">? </span><span style="color: #0000BB">strtolower</span><span style="color: #007700">(</span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$ext</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">)) : </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"file extension: </span><span style="color: #0000BB">$ext</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад виведе щось
схоже на:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">file extension: .txt
file extension: txt</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.strrchr-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: <span class="simpara">Ця функція є бінарно
безпечною.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.strrchr-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.strstr.php" class="function" rel="rdfs-seeAlso">strstr()</a> - Find the first occurrence of a string</span></li>
    <li><span class="function"><a href="function.strrpos.php" class="function" rel="rdfs-seeAlso">strrpos()</a> - Find the position of the last occurrence of a substring in a string</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>