mirror of
https://github.com/php/doc-es.git
synced 2026-04-26 08:38:05 +02:00
9f7804a633
* feat(translation): update revision EN * feat(translation): update revision EN
156 lines
4.7 KiB
XML
156 lines
4.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4225e50bc391ddba99e367c231463da0dc04357d Maintainer: PhilDaiguille Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<refentry xml:id="function.sscanf" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>sscanf</refname>
|
|
<refpurpose>Analiza una cadena utilizando un formato</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>int</type><type>null</type></type><methodname>sscanf</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>format</parameter></methodparam>
|
|
<methodparam rep="repeat"><type>mixed</type><parameter role="reference">vars</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>sscanf</function> es la función inversa de
|
|
<function>printf</function>. <function>sscanf</function> lee
|
|
datos de la cadena <parameter>string</parameter> e
|
|
los interpreta según el formato <parameter>format</parameter>.
|
|
</para>
|
|
<para>
|
|
Todos los caracteres en blanco en la cadena <parameter>format</parameter> corresponden
|
|
a un carácter en blanco en la cadena <parameter>string</parameter>. Esto significa que
|
|
incluso una tabulación (<literal>\t</literal>) en la cadena de formato puede corresponder a
|
|
un simple espacio en la cadena <parameter>str</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>string</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La cadena a analizar.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
&strings.scanf.parameter.format;
|
|
<varlistentry>
|
|
<term><parameter>vars</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Opcionalmente, se pueden pasar variables en este parámetro,
|
|
por referencia que contendrán los valores del análisis.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Si solo se proporcionan dos parámetros, los valores encontrados
|
|
se devolverán como un array. De lo contrario, si se proporcionan los parámetros
|
|
opcionales, la función devolverá el número de
|
|
valores asignados. El parámetro opcional debe pasarse por
|
|
referencia.
|
|
</para>
|
|
<para>
|
|
Si hay más subcadenas esperadas en el parámetro
|
|
<parameter>format</parameter> que las disponibles en
|
|
<parameter>string</parameter>, entonces &null; será devuelto.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo con <function>sscanf</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Lectura de un número de serie
|
|
list($serial) = sscanf("SN/2350001", "SN/%d");
|
|
// y la fecha de fabricación
|
|
$mandate = "January 01 2000";
|
|
list($month, $day, $year) = sscanf($mandate, "%s %d %d");
|
|
echo "El producto $serial fue fabricado el: $year-" . substr($month, 0, 3) . "-$day\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Si se pasan parámetros opcionales, <function>sscanf</function> devolverá
|
|
el número de valores asignados.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>sscanf</function> - uso de parámetros opcionales</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// lee la información del autor y genera una entrada DocBook
|
|
$auth = "24\tLewis Carroll";
|
|
$n = sscanf($auth, "%d\t%s %s", $id, $first, $last);
|
|
echo "<author id='$id'>
|
|
<firstname>$first</firstname>
|
|
<surname>$last</surname>
|
|
</author>\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>printf</function></member>
|
|
<member><function>sprintf</function></member>
|
|
<member><function>fprintf</function></member>
|
|
<member><function>vprintf</function></member>
|
|
<member><function>vsprintf</function></member>
|
|
<member><function>vfprintf</function></member>
|
|
<member><function>fscanf</function></member>
|
|
<member><function>number_format</function></member>
|
|
<member><function>date</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
|
|
-->
|