mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 16:32:13 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334672 c90b9560-bf6c-de11-be94-00142212c4b1
181 lines
4.9 KiB
XML
181 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: e41aab5ecacf449e51179886c17f1d41735b0234 Maintainer: jpberdejo Status: ready -->
|
|
<!-- Reviewed: no Maintainer: andresdzphp -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strrpos">
|
|
<refnamediv>
|
|
<refname>strrpos</refname>
|
|
<refpurpose>Encuentra la posición de la última aparición de un substring en un string</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>strrpos</methodname>
|
|
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Encuentra la posición númerica de la última aparición de
|
|
<parameter>needle</parameter> (aguja) en el string <parameter>haystack</parameter> (pajar).
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>haystack</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
El string donde buscar.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>needle</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si <parameter>needle</parameter> no es un string, se convierte
|
|
en un integer y se aplica como el valor ordinal de un caracter.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>offset</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si se especifica, la búsqueda iniciará en éste número de caracteres contados desde el
|
|
comienzo del string. Si el valor es negativo, entonces la búsqueda iniciará
|
|
desde esa cantidad de caracteres desde el final del string, buscando hacia atrás.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Devuelve la posición donde la aguja existe, en relación al inicio del
|
|
string <parameter>haystack</parameter> (independiente de la dirección de la búsqueda
|
|
o del offset).
|
|
También tener en cuenta que las posiciones de inicio de los string empiezan en 0 y no 1.
|
|
</para>
|
|
<para>
|
|
Devuelve &false; si no fue encontrada la aguja.
|
|
</para>
|
|
&return.falseproblem;
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.0.0</entry>
|
|
<entry>
|
|
<parameter>needle</parameter> puede ser ahora un string de más de un
|
|
carácter.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Verificando si hay una aguja en el pajar</title>
|
|
<para>
|
|
Es fácil confundir el valor devuelto por "caracter encontrado en
|
|
la posición 0" y "caracter no encontrado". Aquí está la forma de detectar
|
|
la diferencia:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$pos = strrpos($mystring, "b");
|
|
if ($pos === false) { // nota: tres signos de igual
|
|
// no encontrado...
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Buscando con desplazamientos</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$foo = "0123456789a123456789b123456789c";
|
|
|
|
var_dump(strrpos($foo, '7', -5)); // Comienza mirando hacia atrás cinco posiciones
|
|
// desde el final. Resultado: int(17)
|
|
|
|
var_dump(strrpos($foo, '7', 20)); // Inicia la búsqueda 20 posiciones en el
|
|
// string. Resultado: int(27)
|
|
|
|
var_dump(strrpos($foo, '7', 28)); // Resultado: bool(false)
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>strpos</function></member>
|
|
<member><function>stripos</function></member>
|
|
<member><function>strripos</function></member>
|
|
<member><function>strrchr</function></member>
|
|
<member><function>substr</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:"~/.phpdoc/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
|
|
-->
|
|
|