cvs: phpdoc /es/functions strings.xml

From: Date: Wed, 29 Nov 2000 15:15:15 +0000
Subject: cvs: phpdoc /es/functions strings.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969333114@lists.php.net to get a copy of this message
rafael Wed Nov 29 07:15:15 2000 EDT Modified files: /phpdoc/es/functions strings.xml Log: Traduction

Index: phpdoc/es/functions/strings.xml diff -u phpdoc/es/functions/strings.xml:1.2 phpdoc/es/functions/strings.xml:1.3 --- phpdoc/es/functions/strings.xml:1.2 Sat Sep 2 07:10:24 2000 +++ phpdoc/es/functions/strings.xml Wed Nov 29 07:15:14 2000 @@ -1,2967 +1,2969 @@ - <reference id="ref.strings"> - <title>String functions</title> - <titleabbrev>Strings</titleabbrev> - - <partintro> - <simpara> - These functions all manipulate strings in various ways. Some more - specialized sections can be found in the regular expression and - URL handling sections. - </simpara> - </partintro> - - <refentry id="function.addcslashes"> - <refnamediv> - <refname>AddCSlashes</refname> - <refpurpose>Quote string with slashes in a C style</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>addcslashes</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string <parameter>charlist</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a string with backslashes before characters that are - listed in <parameter>charlist</parameter> parameter. It escapes - <literal>\n</literal>, <literal>\r</literal> etc. in C-like - style, characters with ASCII code lower than 32 and higher than - 126 are converted to octal representation. Be carefull when - escaping alphanumeric characters. You can specify a range in - <parameter>charlist</parameter> like "\0..\37", which would - escape all characters with ASCII code between 0 and 31. - <example> - <title><function>Addcslashes</function> example</title> - <programlisting role="php"> -$escaped = addcslashes ($not_escaped, "\0..\37!@\177..\377"); - </programlisting> - </example> - <note> - <simpara> - Added in PHP4b3-dev.</simpara> - </note> - </para> - <para> - See also <function>stripcslashes</function>, - <function>stripslashes</function>, - <function>htmlspecialchars</function>, - <function>htmlspecialchars</function>, and - <function>quotemeta</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.addslashes"> - <refnamediv> - <refname>AddSlashes</refname> - <refpurpose>Quote string with slashes</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>addslashes</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a string with backslashes before characters that need - to be quoted in database queries etc. These characters are - single quote (<literal>'</literal>), double quote - (<literal>"</literal>), backslash (<literal>\</literal>) - and NUL (the null byte). - </para> - <para> - See also <function>stripslashes</function>, - <function>htmlspecialchars</function>, and - <function>quotemeta</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.bin2hex"> - <refnamediv> - <refname>bin2hex</refname> - <refpurpose> - Convert binary data into hexadecimal representation - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>bin2hex</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns an ASCII string containing the hexadecimal representation - of <parameter>str</parameter>. The conversion is done byte-wise - with the high-nibble first. - </para> - </refsect1> - </refentry> - - <refentry id="function.chop"> - <refnamediv> - <refname>Chop</refname> - <refpurpose>Remove trailing whitespace</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>chop</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns the argument string without trailing whitespace, - including newlines. - <example> - <title><function>Chop</function> example</title> - <programlisting role="php"> -$trimmed = chop ($line); - </programlisting> - </example> - </para> - <para> - See also <function>trim</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.chr"> - <refnamediv> - <refname>Chr</refname> - <refpurpose>Return a specific character</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>chr</function></funcdef> - <paramdef>int <parameter>ascii</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a one-character string containing the character specified - by <parameter>ascii</parameter>. - <example> - <title><function>Chr</function> example</title> - <programlisting role="php"> -$str .= chr (27); /* add an escape character at the end of $str */ - -/* Often this is more useful */ - -$str = sprintf ("The string ends in escape: %c", 27); - </programlisting> - </example> - This function complements <function>ord</function>. See also - <function>sprintf</function> with a format string of - <literal>%c</literal>. - </para> - </refsect1> - </refentry> - - <refentry id="function.chunk-split"> - <refnamediv> - <refname>chunk_split</refname> - <refpurpose>Split a string into smaller chunks</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>chunk_split</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - <paramdef>int - <parameter><optional>chunklen</optional></parameter> - </paramdef> - <paramdef>string - <parameter><optional>end</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Can be used to split a string into smaller chunks which is useful - for e.g. converting <link - linkend="function.base64-encode">base64_encode</link> output to - match RFC 2045 semantics. It inserts every - <parameter>chunklen</parameter> (defaults to 76) chars the string - <parameter>end</parameter> (defaults to "\r\n"). It returns the - new string leaving the original string untouched. - <example> - <title><function>Chunk_split</function> example</title> - <programlisting role="php"> -# format $data using RFC 2045 semantics - -$new_string = chunk_split (base64_encode($data)); - </programlisting> - </example> - This function is significantly faster than - <function>ereg_replace</function>. - <note> - <para> - This function was added in 3.0.6. - </para> - </note> - </para> - </refsect1> - </refentry> - - <refentry id="function.convert-cyr-string"> - <refnamediv> - <refname>convert_cyr_string</refname> - <refpurpose> - Convert from one Cyrillic character set to another - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>convert_cyr_string</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string <parameter>from</parameter></paramdef> - <paramdef>string <parameter>to</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function converts the given string from one Cyrillic - character set to another. The <parameter>from</parameter> and - <parameter>to</parameter> arguments are single characters that - represent the source and target Cyrillic character sets. The - supported types are: - <itemizedlist> - <listitem> - <simpara> - k - koi8-r - </simpara> - </listitem> - <listitem> - <simpara> - w - windows-1251 - </simpara> - </listitem> - <listitem> - <simpara> - i - iso8859-5 - </simpara> - </listitem> - <listitem> - <simpara> - a - x-cp866 - </simpara> - </listitem> - <listitem> - <simpara> - d - x-cp866 - </simpara> - </listitem> - <listitem> - <simpara> - m - x-mac-cyrillic - </simpara> - </listitem> - </itemizedlist> - </para> - </refsect1> - </refentry> - - <refentry id="function.count-chars"> - <refnamediv> - <refname>count_chars</refname> - <refpurpose> - Return information abouts characters used in a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>mixed <function>count_chars</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - <paramdef> - <parameter> - <optional>mode</optional> - </parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Counts the number of occurances of every byte-value (0..255) in - <parameter>string</parameter> and returns it in various ways. - The optional parameter <parameter>Mode</parameter> default to - 0. Depending on <parameter>mode</parameter> - <function>count_chars</function> returns one of the following: - <itemizedlist> - <listitem> - <simpara> - 0 - an array with the byte-value as key and the freqency of - every byte as value. - </simpara> - </listitem> - <listitem> - <simpara> - 1 - same as 0 but only byte-values with a frequency greater - than zero are listed. - </simpara> - </listitem> - <listitem> - <simpara> - 2 - same as 0 but only byte-values with a frequency equal to - zero are listed. - </simpara> - </listitem> - <listitem> - <simpara> - 3 - a string containing all used byte-values is returned. - </simpara> - </listitem> - <listitem> - <simpara> - 4 - a string containing all not used byte-values is returned. - </simpara> - </listitem> - </itemizedlist> - </para> - <note> - <para> - This function was added in PHP 4.0. - </para> - </note> - </refsect1> - </refentry> - - <refentry id="function.crc32"> - <refnamediv> - <refname>crc32</refname> - <refpurpose>Calculates the crc32 polynomial of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>crc32</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Generates the cyclic redundancy checksum polynomial of 32-bit lengths of - the <parameter>str</parameter>. This is usually used to validate the - integrity of data being trasmited. - </para> - <para> - See also: <function>md5</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.crypt"> - <refnamediv> - <refname>crypt</refname> - <refpurpose>DES-encrypt a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>crypt</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string - <parameter><optional>salt</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - <function>crypt</function> will encrypt a string using the - standard Unix <abbrev>DES</abbrev> encryption method. Arguments - are a string to be encrypted and an optional two-character salt - string to base the encryption on. See the Unix man page for your - crypt function for more information. - </para> - <simpara> - If the salt argument is not provided, it will be randomly - generated by PHP. - </simpara> - <simpara> - Some operating systems support more than one type of encryption. - In fact, sometimes the standard DES encryption is replaced by an - MD5 based encryption algorithm. The encryption type is triggered - by the salt argument. At install time, PHP determines the - capabilities of the crypt function and will accept salts for - other encryption types. If no salt is provided, PHP will - auto-generate a standard 2-character DES salt by default unless - the default encryption type on the system is MD5 in which case a - random MD5-compatible salt is generated. PHP sets a constant - named CRYPT_SALT_LENGTH which tells you whether a regular - 2-character salt applies to your system or the longer 12-char MD5 - salt is applicable. - </simpara> - <simpara> - The standard DES encryption <function>crypt</function> contains - the salt as the first two characters of the output. - </simpara> - <simpara> - On systems where the crypt() function supports multiple - encryption types, the following constants are set to 0 or 1 - depending on whether the given type is available: - </simpara> - <itemizedlist> - <listitem> - <simpara> - CRYPT_STD_DES - Standard DES encryption with a 2-char SALT - </simpara> - </listitem> - <listitem> - <simpara> - CRYPT_EXT_DES - Extended DES encryption with a 9-char SALT - </simpara> - </listitem> - <listitem> - <simpara> - CRYPT_MD5 - MD5 encryption with a 12-char SALT starting with - $1$ - </simpara> - </listitem> - <listitem> - <simpara> - CRYPT_BLOWFISH - Extended DES encryption with a 16-char SALT - starting with $2$ - </simpara> - </listitem> - </itemizedlist> - <simpara> - There is no decrypt function, since <function>crypt</function> - uses a one-way algorithm. - </simpara> - <simpara> - See also: <function>md5</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.echo"> - <refnamediv> - <refname>echo</refname> - <refpurpose>Output one or more strings</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef><function>echo</function></funcdef> - <paramdef>string <parameter>arg1</parameter></paramdef> - <paramdef>string - <parameter><optional>argn</optional>...</parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Outputs all parameters. - </simpara> - <para> - <function>Echo</function> is not actually a function (it is a - language construct) so you are not required to use parantheses - with it. - <example> - <title><function>Echo</function> example</title> - <programlisting role="php"> -echo "Hello World"; - -echo "This spans -multiple lines. The newlines will be -output as well"; - -echo "This spans\nmultiple lines. The newlines will be\noutput as well."; - </programlisting> - </example> - </para> - <note> - <para> - In fact, if you want to pass more than one parameter to echo, - you must not enclose the parameters within parentheses. - </para> - </note> - <simpara> - See also: - <function>print</function>, - <function>printf</function>, and - <function>flush</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.explode"> - <refnamediv> - <refname>explode</refname> - <refpurpose>Split a string by string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>array <function>explode</function></funcdef> - <paramdef>string <parameter>separator</parameter></paramdef> - <paramdef>string <parameter>string</parameter></paramdef> - <paramdef>int - <parameter><optional>limit</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns an array of strings, each of which is a substring of - <parameter>string</parameter> formed by splitting it on boundaries formed - by the string <parameter>delim</parameter>. - If <parameter>limit</parameter> is set, the returned array will contaion - a maximum of <parameter>limit</parameter> elements with the last element - containing the whole rest of <parameter>string</parameter>. - </para> - <para> - <example> - <title><function>Explode</function> example</title> - <programlisting role="php"> -$pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; -$pieces = explode (" ", $pizza); - </programlisting> - </example> - </para> - <para> - See also <function>split</function> and - <function>implode</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.get-html-translation-table"> - <refnamediv> - <refname>get_html_translation_table</refname> - <refpurpose> - Returns the translation table used by - <function>htmlspecialchars</function> and - <function>htmlentities</function> - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string - <function>get_html_translation_table</function> - </funcdef> - <paramdef>int <parameter>table</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - <function>get_html_translation_table</function> will return the - translation table that is used internally for - <function>htmlspecialchars</function> and - <function>htmlentities</function>. Ther are two new defines - (<parameter>HTML_ENTITIES</parameter>, - <parameter>HTML_SPECIALCHARS</parameter>) that allow you to - specify the table you want. - <example> - <title>Translation Table Example</title> - <programlisting role="php"> -$trans = get_html_translation_table (HTML_ENTITIES); -$str = "Hallo &amp; &lt;Frau> &amp; Kr&auml;mer"; -$encoded = strtr ($str, $trans); - </programlisting> - </example> - The <literal>$encoded</literal> variable will now contain: "Hallo - &amp;<sgmltag>amp</sgmltag>; - &amp;<sgmltag>lt</sgmltag>;Frau&amp;<sgmltag>gt</sgmltag>; - &amp;<sgmltag>amp</sgmltag>; Kr&amp;<sgmltag>auml</sgmltag>;mer". - </para> - <para> - The cool thing is using <function>array_flip</function> to change - the direction of the translation. - <informalexample> - <programlisting role="php"> -$trans = array_flip ($trans); -$original = strtr ($str, $trans); - </programlisting> - </informalexample> - The content of <literal>$original</literal> would be: "Hallo &amp; - &lt;Frau> &amp; Kr&auml;mer". - <note> - <para> - This function was added in PHP 4.0. - </para> - </note> - </para> - <para> - See also: <function>htmlspecialchars</function>, - <function>htmlentities</function>, <function>strtr</function>, - and <function>array_flip</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.get-meta-tags"> - <refnamediv> - <refname>get_meta_tags</refname> - <refpurpose> - Extracts all meta tag content attributes from a file and returns - an array - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>array <function>get_meta_tags</function></funcdef> - <paramdef>string <parameter>filename</parameter></paramdef> - <paramdef>int - <parameter><optional>use_include_path</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Opens <parameter>filename</parameter> and parses it line by line - for &lt;meta> tags of the form - <example> - <title>Meta Tags Example</title> - <programlisting role="html"> -&lt;meta name="author" content="name"> -&lt;meta name="tags" content="php3 documentation"> -&lt;/head> &lt;!-- parsing stops here --> - </programlisting> - </example> - (pay attention to line endings - PHP uses a native function to - parse the input, so a Mac file won't work on Unix). - </para> - <para> - The value of the name property becomes the key, the value of the - content property becomes the value of the returned array, so you - can easily use standard array functions to traverse it or access - single values. Special characters in the value of the name - property are substituted with '_', the rest is converted to lower - case. - </para> - <para> - Setting <parameter>use_include_path</parameter> to 1 will result - in PHP trying to open the file along the standard include path. - </para> - </refsect1> - </refentry> - - <refentry id="function.hebrev"> - <refnamediv> - <refname>hebrev</refname> - <refpurpose> - Convert logical Hebrew text to visual text - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>hebrev</function></funcdef> - <paramdef>string <parameter>hebrew_text</parameter></paramdef> - <paramdef>int - <parameter><optional>max_chars_per_line</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - The optional parameter <parameter>max_chars_per_line</parameter> - indicates maximum number of characters per line will be output. The - function tries to avoid breaking words. - </para> - <para> - See also <function>hebrevc</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.hebrevc"> - <refnamediv> - <refname>hebrevc</refname> - <refpurpose> - Convert logical Hebrew text to visual text with newline conversion - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>hebrevc</function></funcdef> - <paramdef>string <parameter>hebrew_text</parameter></paramdef> - <paramdef>int - <parameter><optional>max_chars_per_line</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function is similar to <function>hebrev</function> with the - difference that it converts newlines (\n) to "&lt;br&gt;\n". - The optional parameter <parameter>max_chars_per_line</parameter> - indicates maximum number of characters per line will be output. The - function tries to avoid breaking words. - </para> - <para> - See also <function>hebrev</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.htmlentities"> - <refnamediv> - <refname>htmlentities</refname> - <refpurpose> - Convert all applicable characters to HTML entities - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>htmlentities</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function is identical to - <function>Htmlspecialchars</function> in all ways, except that - all characters which have HTML entity equivalents are translated - into these entities. - </para> - <para> - At present, the ISO-8859-1 character set is used. - </para> - <para> - See also <function>htmlspecialchars</function> and - <function>nl2br</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.htmlspecialchars"> - <refnamediv> - <refname>htmlspecialchars</refname> - <refpurpose> - Convert special characters to HTML entities - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>htmlspecialchars</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Certain characters have special significance in HTML, and should - be represented by HTML entities if they are to preserve their - meanings. This function returns a string with these conversions - made. - </para> - <simpara> - This function is useful in preventing user-supplied text from - containing HTML markup, such as in a message board or guest book - application. - </simpara> - <para> - At present, the translations that are done are: - <itemizedlist> - <listitem> - <simpara> - '&amp;' (ampersand) becomes '&amp;amp;' - </simpara> - </listitem> - <listitem> - <simpara> - '&quot;' (double quote) becomes '&amp;quot;' - </simpara> - </listitem> - <listitem> - <simpara> - '&lt;' (less than) becomes '&amp;lt;' - </simpara> - </listitem> - <listitem> - <simpara> - '&gt;' (greater than) becomes '&amp;gt;' - </simpara> - </listitem> - </itemizedlist> - </para> - <para> - Note that this functions does not translate anything beyond what - is listed above. For full entity translation, see - <function>htmlentities</function>. - </para> - <para> - See also <function>htmlentities</function> and - <function>nl2br</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.implode"> - <refnamediv> - <refname>implode</refname> - <refpurpose>Join array elements with a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>implode</function></funcdef> - <paramdef>string <parameter>glue</parameter></paramdef> - <paramdef>array <parameter>pieces</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a string containing a string representation of all the - array elements in the same order, with the glue string between - each element. - <example> - <title><function>Implode</function> example</title> - <programlisting role="php"> -$colon_separated = implode (":", $array); - </programlisting> - </example> - </para> - <simpara> - See also <function>explode</function>, <function>join</function>, - and <function>split</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.join"> - <refnamediv> - <refname>join</refname> - <refpurpose>Join array elements with a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>join</function></funcdef> - <paramdef>string <parameter>glue</parameter></paramdef> - <paramdef>array <parameter>pieces</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - <function>join</function> is an alias to - <function>implode</function>, and is identical in every way. - </simpara> - <simpara> - See also <function>explode</function>, <function>implode</function>, - and <function>split</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.levenshtein"> - <refnamediv> - <refname>levenshtein</refname> - <refpurpose> - Calculate Levenshtein distance between two strings - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>levenshtein</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function return the Levenshtein-Distance between the two - argument strings or -1, if one of the argument strings is longer - than the limit of 255 characters. - </para> - <para> - The Levenshtein distance is defined as the minimal number of - characters you have to replace, insert or delete to transform - <parameter>str1</parameter> into <parameter>str2</parameter>. - The complexity of the algorithm is <literal>O(m*n)</literal>, - where <literal>n</literal> and <literal>m</literal> are the - length of <parameter>str1</parameter> and - <parameter>str2</parameter> (rather good when compared to - <function>similar_text</function>, which is O(max(n,m)**3), but - still expensive). - </para> - <para> - See also <function>soundex</function>, - <function>similar_text</function> and - <function>metaphone</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.ltrim"> - <refnamediv> - <refname>ltrim</refname> - <refpurpose> - Strip whitespace from the beginning of a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>ltrim</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function strips whitespace from the start of a string and - returns the stripped string. The whitespace - characters it currently strips are: "\n", "\r", "\t", "\v", "\0", - and a plain space. - </para> - <para> - See also <function>chop</function> and <function>trim</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.md5"> - <refnamediv> - <refname>md5</refname> - <refpurpose>Calculate the md5 hash of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>md5</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Calculates the MD5 hash of <parameter>str</parameter> using the - <ulink url="&url.rfc;rfc1321.html">RSA Data Security, Inc. - MD5 Message-Digest Algorithm</ulink>. - </para> - <para> - See also: <function>crc32</function> - </para> - </refsect1> - </refentry> - - <refentry id="function.metaphone"> - <refnamediv> - <refname>Metaphone</refname> - <refpurpose>Calculate the metaphone key of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>metaphone</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Calculates the metaphone key of <parameter>str</parameter>. - </para> - <para> - Similar to <function>soundex</function> metaphone creates the - same key for similar sounding words. It's more accurate than - <function>soundex</function> as it knows the basic rules of - English pronunciation. The metaphone generated keys are of - variable length. - </para> - <para> - Metaphone was developed by Lawrence Philips - &lt;lphilips@verity.com>. It is described in ["Practical - Algorithms for Programmers", Binstock &amp; Rex, Addison Wesley, - 1995]. - <note> - <para> - This function was added in PHP 4.0. - </para> - </note> - </para> - </refsect1> - </refentry> - - <refentry id="function.nl2br"> - <refnamediv> - <refname>nl2br</refname> - <refpurpose>Converts newlines to HTML line breaks</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>nl2br</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns <parameter>string</parameter> with '&lt;BR&gt;' inserted - before all newlines. - </para> - <para> - See also <function>htmlspecialchars</function>, - <function>htmlentities</function> and - <function>wordwrap</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.ord"> - <refnamediv> - <refname>Ord</refname> - <refpurpose>Return ASCII value of character</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>ord</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns the ASCII value of the first character of - <parameter>string</parameter>. This function complements - <function>chr</function>. - <example> - <title><function>Ord</function> example</title> - <programlisting role="php"> -if (ord ($str) == 10) { - echo "The first character of \$str is a line feed.\n"; -} - </programlisting> - </example> - </para> - <simpara> - See also <function>chr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.parse-str"> - <refnamediv> - <refname>parse_str</refname> - <refpurpose>Parses the string into variables</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>void <function>parse_str</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Parses <parameter>str</parameter> as if it were the query string - passed via an URL and sets variables in the current scope. - </para> - <para> - <example> - <title>Using <function>parse_str</function></title> - <programlisting role="php"> -$str = "first=value&amp;second[]=this+works&amp;second[]=another"; -parse_str($str); -echo $first; /* prints "value" */ -echo $second[0]; /* prints "this works" */ -echo $second[1]; /* prints "another" */ - </programlisting> - </example> - </para> - </refsect1> - </refentry> - - <refentry id="function.print"> - <refnamediv> - <refname>print</refname> - <refpurpose>Output a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef><function>print</function></funcdef> - <paramdef>string <parameter>arg</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Outputs <parameter>arg</parameter>. - </simpara> - <simpara> - See also: <function>echo</function>, <function>printf</function>, - and <function>flush</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.printf"> - <refnamediv> - <refname>printf</refname> - <refpurpose>Output a formatted string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>printf</function></funcdef> - <paramdef>string <parameter>format</parameter></paramdef> - <paramdef>mixed - <parameter><optional>args</optional></parameter>... - </paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Produces output according to <parameter>format</parameter>, which - is described in the documentation for <function>sprintf</function>. - </simpara> - <simpara> - See also: <function>print</function>, <function>sprintf</function>, - <function>sscanf</function>, <function>fscanf</function>, - and <function>flush</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.quoted-printable-decode"> - <refnamediv> - <refname>quoted_printable_decode</refname> - <refpurpose> - Convert a quoted-printable string to an 8 bit string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string - <function>quoted_printable_decode</function> - </funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - This function returns an 8-bit binary string corresponding to the - decoded quoted printable string. This function is similar to - <function>imap_qprint</function>, except this one does not - require the IMAP module to work. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.quotemeta"> - <refnamediv> - <refname>quotemeta</refname> - <refpurpose>Quote meta characters</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>quotemeta</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a version of str with a backslash character - (<literal>\</literal>) before every character that is among - these: <screen>. \\ + * ? [ ^ ] ( $ )</screen> - </para> - <simpara> - See also <function>addslashes</function>, - <function>htmlentities</function>, - <function>htmlspecialchars</function>, - <function>nl2br</function>, and - <function>stripslashes</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.rtrim"> - <refnamediv> - <refname>rtrim</refname> - <refpurpose>Remove trailing whitespace.</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcdef>string <function>rtrim</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcsynopsis> - <para> - Returns the argument string without trailing whitespace, - including newlines. This is an alias for <function>chop</function>. - <example> - <title><function>rtrim</function> example</title> - <programlisting role="php"> -$trimmed = rtrim ($line); - </programlisting> - </example> - </para> - <para> - See also <function>trim</function>, <function>ltrim</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.sscanf"> - <refnamediv> - <refname>sscanf</refname> - <refpurpose>Parses input from a string according to a format</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>mixed <function>sscanf</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string <parameter>format</parameter></paramdef> - <paramdef>string - <parameter><optional>var1</optional></parameter>... - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - The function <function>sscanf</function> is the input analog of - <function>printf</function>. <function>Sscanf</function> reads from - the string <parameter>str</parameter> and interprets it according to - the specified <parameter>format</parameter>. If only two parameters were - passed to this function, the values parsed will be returned as an array. - <example> - <title><function>Sscanf</function> Example</title> - <programlisting role="php"> -// getting the serial number -$serial = sscanf("SN/2350001","SN/%d"); -// and the date of manufacturing -$mandate = "January 01 2000"; -list($month, $day, $year) = sscanf($mandate,"%s %d %d"); -echo "Item $serial was manufactured on: $year-".substr($month,0,3)."-$day\n"; - </programlisting> - </example> - If optional parameters are passed, the function will return the number of - assigned values. The optional parameters must be passed by reference. - <example> - <title><function>Sscanf</function> - using optional parameters</title> - <programlisting role="php"> -// get author info and generate DocBook entry -$auth = "24\tLewis Carroll"; -$n = sscanf($auth,"%d\t%s %s", &amp;$id, &amp;$first, &amp;$last); -echo "&lt;author id='$id'&gt; - &lt;firstname&gt;$first&lt;/firstname&gt; - &lt;surname&gt;$last&lt;/surname&gt; -&lt;/author&gt;\n"; - </programlisting> - </example> - </para> - <para> - See also: <function>fscanf</function>, <function>printf</function>, - and <function>sprintf</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.setlocale"> - <refnamediv> - <refname>setlocale</refname> - <refpurpose>Set locale information</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>setlocale</function></funcdef> - <paramdef>string <parameter>category</parameter></paramdef> - <paramdef>string <parameter>locale</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - <parameter>Category</parameter> is a string specifying the - category of the functions affected by the locale setting: - <itemizedlist> - <listitem> - <simpara> - LC_ALL for all of the below - </simpara> - </listitem> - <listitem> - <simpara> - LC_COLLATE for string comparison - not currently implemented in PHP - </simpara> - </listitem> - <listitem> - <simpara> - LC_CTYPE for character classification and conversion, for - example <function>strtoupper</function> - </simpara> - </listitem> - <listitem> - <simpara> - LC_MONETARY for localeconv() - not currently implemented in - PHP - </simpara> - </listitem> - <listitem> - <simpara> - LC_NUMERIC for decimal separator - </simpara> - </listitem> - <listitem> - <simpara> - LC_TIME for date and time formatting with - <function>strftime</function> - </simpara> - </listitem> - </itemizedlist> - </para> - <para> - If <parameter>locale</parameter> is the empty string - <literal>""</literal>, the locale names will be set from the - values of environment variables with the same names as the above - categories, or from "LANG". - </para> - <para> - If locale is zero or <literal>"0"</literal>, the locale setting - is not affected, only the current setting is returned. - </para> - <para> - Setlocale returns the new current locale, or false if the locale - functionality is not implemented in the plattform, the specified - locale does not exist or the category name is invalid. - An invalid category name also causes a warning message. - </para> - </refsect1> - </refentry> - - <refentry id="function.similar-text"> - <refnamediv> - <refname>similar_text</refname> - <refpurpose> - Calculate the similarity between two strings - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>similar_text</function></funcdef> - <paramdef>string <parameter>first</parameter></paramdef> - <paramdef>string <parameter>second</parameter></paramdef> - <paramdef>double - <parameter><optional>percent</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - This calculates the similarity between two strings as described - in Oliver [1993]. Note that this implementation does not use a - stack as in Oliver's pseudo code, but recursive calls which may - or may not speed up the whole process. Note also that the - complexity of this algorithm is O(N**3) where N is the length of - the longest string. - </para> - <para> - By passing a reference as third argument, - <function>similar_text</function> will calculate the similarity - in percent for you. It returns the number of matching chars in - both strings. - </para> - </refsect1> - </refentry> - - <refentry id="function.soundex"> - <refnamediv> - <refname>soundex</refname> - <refpurpose>Calculate the soundex key of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>soundex</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Calculates the soundex key of <parameter>str</parameter>. - </para> - <para> - Soundex keys have the property that words pronounced similarly - produce the same soundex key, and can thus be used to simplify - searches in databases where you know the pronunciation but not - the spelling. This soundex function returns a string 4 characters - long, starting with a letter. - </para> - <para> - This particular soundex function is one described by Donald Knuth - in "The Art Of Computer Programming, vol. 3: Sorting And - Searching", Addison-Wesley (1973), pp. 391-392. - </para> - <para> - <example> - <title>Soundex Examples</title> - <programlisting role="php"> -soundex ("Euler") == soundex ("Ellery") == 'E460'; -soundex ("Gauss") == soundex ("Ghosh") == 'G200'; -soundex ("Knuth") == soundex ("Kant") == 'H416'; -soundex ("Lloyd") == soundex ("Ladd") == 'L300'; -soundex ("Lukasiewicz") == soundex ("Lissajous") == 'L222'; - </programlisting> - </example> - </para> - </refsect1> - </refentry> - - <refentry id="function.sprintf"> - <refnamediv> - <refname>sprintf</refname> - <refpurpose>Return a formatted string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>sprintf</function></funcdef> - <paramdef>string <parameter>format</parameter></paramdef> - <paramdef>mixed - <parameter><optional>args</optional></parameter>... - </paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Returns a string produced according to the formatting string - <parameter>format</parameter>. - </simpara> - <simpara> - The format string is composed by zero or more directives: - ordinary characters (excluding <literal>%</literal>) that are - copied directly to the result, and <emphasis>conversion - specifications</emphasis>, each of which results in fetching its - own parameter. This applies to both <function>sprintf</function> - and <function>printf</function>. - </simpara> - <para> - Each conversion specification consists of these elements, in - order: - <orderedlist> - <listitem> - <simpara> - An optional <emphasis>padding specifier</emphasis> that says - what character will be used for padding the results to the - right string size. This may be a space character or a - <literal>0</literal> (zero character). The default is to pad - with spaces. An alternate padding character can be specified - by prefixing it with a single quote (<literal>'</literal>). - See the examples below. - </simpara> - </listitem> - <listitem> - <simpara> - An optional <emphasis>alignment specifier</emphasis> that says - if the result should be left-justified or right-justified. - The default is right-justified; a <literal>-</literal> - character here will make it left-justified. - </simpara> - </listitem> - <listitem> - <simpara> - An optional number, a <emphasis>width specifier</emphasis> - that says how many characters (minimum) this conversion should - result in. - </simpara> - </listitem> - <listitem> - <simpara> - An optional <emphasis>precision specifier</emphasis> that says - how many decimal digits should be displayed for floating-point - numbers. This option has no effect for other types than - double. (Another function useful for formatting numbers is - <function>number_format</function>.) - </simpara> - </listitem> - <listitem> - <para> - A <emphasis>type specifier</emphasis> that says what type the - argument data should be treated as. Possible types: - <simplelist> - <member> - <literal>%</literal> - a literal percent character. No - argument is required. - </member> - <member> - <literal>b</literal> - the argument is treated as an - integer, and presented as a binary number. - </member> - <member> - <literal>c</literal> - the argument is treated as an - integer, and presented as the character with that ASCII - value. - </member> - <member> - <literal>d</literal> - the argument is treated as an - integer, and presented as a decimal number. - </member> - <member> - <literal>f</literal> - the argument is treated as a double, - and presented as a floating-point number. - </member> - <member> - <literal>o</literal> - the argument is treated as an - integer, and presented as an octal number. - </member> - <member> - <literal>s</literal> - the argument is treated as and - presented as a string. - </member> - <member> - <literal>x</literal> - the argument is treated as an integer - and presented as a hexadecimal number (with lowercase - letters). - </member> - <member> - <literal>X</literal> - the argument is treated as an integer - and presented as a hexadecimal number (with uppercase - letters). - </member> - </simplelist> - </para> - </listitem> - </orderedlist> - </para> - <simpara> - See also: <function>printf</function>, <function>sscanf</function>, - <function>fscanf</function>, and <function>number_format</function>. - </simpara> - </refsect1> - <refsect1> - <title>Examples</title> - <para> - <example> - <title><function>Sprintf</function>: zero-padded integers</title> - <programlisting role="php"> -$isodate = sprintf ("%04d-%02d-%02d", $year, $month, $day); - </programlisting> - </example> - <example> - <title><function>Sprintf</function>: formatting currency</title> - <programlisting role="php"> -$money1 = 68.75; -$money2 = 54.35; -$money = $money1 + $money2; -// echo $money will output "123.1"; -$formatted = sprintf ("%01.2f", $money); -// echo $formatted will output "123.10" - </programlisting> - </example> - </para> - </refsect1> - </refentry> - - <refentry id="function.strcasecmp"> - <refnamediv> - <refname>strcasecmp</refname> - <refpurpose> - Binary safe case-insensitive string comparison - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strcasecmp</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns &lt; 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter> - is greater than <parameter>str2</parameter>, and 0 if they are - equal. - <example> - <title><function>strcasecmp</function> example</title> - <programlisting role="php"> -$var1 = "Hello"; -$var2 = "hello"; -if (!strcasecmp ($var1, $var2)) { - echo '$var1 is equal to $var2 in a case-insensitive string comparison'; -} - </programlisting> - </example> - </para> - <simpara> - See also <function>ereg</function>, <function>strcmp</function>, - <function>substr</function>, <function>stristr</function>, and - <function>strstr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strchr"> - <refnamediv> - <refname>strchr</refname> - <refpurpose> - Find the first occurrence of a character - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strchr</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function is an alias for <function>strstr</function>, and is - identical in every way. - </para> - </refsect1> - </refentry> - - <refentry id="function.strcmp"> - <refnamediv> - <refname>strcmp</refname> - <refpurpose>Binary safe string comparison</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strcmp</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Returns &lt; 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter> - is greater than <parameter>str2</parameter>, and 0 if they are - equal. - </simpara> - <simpara> - Note that this comparison is case sensitive. - </simpara> - <simpara> - See also <function>ereg</function>, - <function>strcasecmp</function>, <function>substr</function>, - <function>stristr</function>, <function>strncmp</function>, - and <function>strstr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strcspn"> - <refnamediv> - <refname>strcspn</refname> - <refpurpose> - Find length of initial segment not matching mask - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strcspn</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Returns the length of the initial segment of - <parameter>str1</parameter> which does <emphasis>not</emphasis> - contain any of the characters in <parameter>str2</parameter>. - </simpara> - <simpara> - See also <function>strspn</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strip-tags"> - <refnamediv> - <refname>strip_tags</refname> - <refpurpose>Strip HTML and PHP tags from a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strip_tags</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string - <parameter><optional>allowable_tags</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function tries to strip all HTML and PHP tags from the given - string. It errors on the side of caution in case of incomplete - or bogus tags. It uses the same tag stripping state machine as - the <function>fgetss</function> function. - </para> - <para> - You can use the optional second parameter to specify tags which - should not be stripped. - <note> - <para> - <parameter>Allowable_tags</parameter> was added in PHP 3.0.13, - PHP4B3. - </para> - </note> - </para> - </refsect1> - </refentry> - - <refentry id="function.stripcslashes"> - <refnamediv> - <refname>stripcslashes</refname> - <refpurpose> - Un-quote string quoted with <function>addcslashes</function> - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>stripcslashes</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a string with backslashes stripped off. Recognizes - C-like <literal>\n</literal>, <literal>\r</literal> ..., octal - and hexadecimal representation. - <note> - <simpara> - Added in PHP4b3-dev. - </simpara> - </note> - </para> - <simpara> - See also <function>addcslashes</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.stripslashes"> - <refnamediv> - <refname>stripslashes</refname> - <refpurpose> - Un-quote string quoted with <function>addslashes</function> - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>stripslashes</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns a string with backslashes stripped off. - (<literal>\'</literal> becomes <literal>'</literal> and so on.) - Double backslashes are made into a single backslash. - </para> - <simpara> - See also <function>addslashes</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.stristr"> - <refnamediv> - <refname>stristr</refname> - <refpurpose> - Case-insensitive <function>strstr</function> - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>stristr</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns all of <parameter>haystack</parameter> from the first - occurrence of <parameter>needle</parameter> to the end. - <parameter>needle</parameter> and <parameter>haystack</parameter> - are examined in a case-insensitive manner. - </para> - <para> - If <parameter>needle</parameter> is not found, returns false. - </para> - <para> - If <parameter>needle</parameter> is not a string, it is converted - to an integer and applied as the ordinal value of a character. - </para> - <para> - See also <function>strchr</function>, - <function>strrchr</function>, <function>substr</function>, and - <function>ereg</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strlen"> - <refnamediv> - <refname>strlen</refname> - <refpurpose>Get string length</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strlen</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns the length of <parameter>string</parameter>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strnatcmp"> - <refnamediv> - <refname>strnatcmp</refname> - <refpurpose> - String comparisons using a "natural order" algorithm - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strnatcmp</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function implements a comparison algorithm that orders - alphanumeric strings in the way a human being would, this is - described as a "natural ordering". An example of the difference - between this algorithm and the regular computer string sorting - algorithms (used in <function>strcmp</function>) can be seen - below: - <informalexample> - <programlisting> -$arr1 = $arr2 = array ("img12.png","img10.png","img2.png","img1.png"); -echo "Standard string comparison\n"; -usort($arr1,"strcmp"); -print_r($arr1); -echo "\nNatural order string comparison\n"; -usort($arr2,"strnatcmp"); -print_r($arr2); - </programlisting> - </informalexample> - The code above will generate the following output: - <informalexample> - <programlisting> -Standard string comparison -Array -( - [0] =&gt; img1.png - [1] =&gt; img10.png - [2] =&gt; img12.png - [3] =&gt; img2.png -) - -Natural order string comparison -Array -( - [0] =&gt; img1.png - [1] =&gt; img2.png - [2] =&gt; img10.png - [3] =&gt; img12.png -) - </programlisting> - </informalexample> - For more infomation see: Martin Pool's <ulink - url="&url.strnatcmp;">Natural Order String Comparison</ulink> - page. - </para> - <simpara> - Similar to other string comparison functions, this one returns - &lt; 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter> - is greater than <parameter>str2</parameter>, and 0 if they are - equal. - </simpara> - <simpara> - Note that this comparison is case sensitive. - </simpara> - <simpara> - See also <function>ereg</function>, - <function>strcasecmp</function>, <function>substr</function>, - <function>stristr</function>, <function>strcmp</function>, - <function>strncmp</function>, <function>strnatcasecmp</function>, - and <function>strstr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strnatcasecmp"> - <refnamediv> - <refname>strnatcasecmp</refname> - <refpurpose> - Case insensitive string comparisons using a "natural order" algorithm - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strnatcasecmp</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function implements a comparison algorithm that orders - alphanumeric strings in the way a human being would. The - behavior of this function is similar to - <function>strnatcmp</function>, except that the comparison is - not case sensitive. For more infomation see: Martin Pool's - <ulink url="&url.strnatcmp;">Natural Order String - Comparison</ulink> page. - </para> - <simpara> - Similar to other string comparison functions, this one returns - &lt; 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter> - is greater than <parameter>str2</parameter>, and 0 if they are - equal. - </simpara> - <simpara> - See also <function>ereg</function>, - <function>strcasecmp</function>, <function>substr</function>, - <function>stristr</function>, <function>strcmp</function>, - <function>strncmp</function>, <function>strnatcmp</function>, - and <function>strstr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strncmp"> - <refnamediv> - <refname>strncmp</refname> - <refpurpose> - Binary safe string comparison of the first n characters - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strncmp</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - <paramdef>int <parameter>len</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function is similar to <function>strcmp</function>, with the - difference that you can specify the (upper limit of the) number of - characters (<parameter>len</parameter>) from each string to be - used in the comparison. If any of the strings is shorter than - <parameter>len</parameter>, then the length of that string will be - used for the comparison. - </para> - <simpara> - Returns &lt; 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter> - is greater than <parameter>str2</parameter>, and 0 if they are - equal. - </simpara> - <simpara> - Note that this comparison is case sensitive. - </simpara> - <simpara> - See also <function>ereg</function>, - <function>strcasecmp</function>, <function>substr</function>, - <function>stristr</function>, <function>strcmp</function>, - and <function>strstr</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.str-pad"> - <refnamediv> - <refname>str_pad</refname> - <refpurpose>Pad a string to a certain length with another string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>str_pad</function></funcdef> - <paramdef>string <parameter>input</parameter></paramdef> - <paramdef>int <parameter>pad_length</parameter></paramdef> - <paramdef>string - <parameter><optional>pad_string</optional></parameter></paramdef> - <paramdef>int - <parameter><optional>pad_type</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - This functions pads the <parameter>input</parameter> string on - the left, the right, or both sides to the specifed padding - length. If the optional argument - <parameter>pad_string</parameter> is not supplied, the - <parameter>input</parameter> is padded with spaces, otherwise it - is padded with characters from <parameter>pad_string</parameter> - up to the limit. - </para> - - <para> - Optional argument <parameter>pad_type</parameter> can be - STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH. If - <parameter>pad_type</parameter> is not specified it is assumed to - be STR_PAD_RIGHT. - </para> - - <para> - If the value of <parameter>pad_length</parameter> is negative or - less than the length of the input string, no padding takes - place. - </para> - - <para> - <example> - <title><function>str_pad</function> example</title> - <programlisting role="php"> -$input = "Alien"; -print str_pad($input, 10); // produces "Alien " -print str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien" -print str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___" - </programlisting> - </example> - </para> - </refsect1> - </refentry> - - <refentry id="function.strpos"> - <refnamediv> - <refname>strpos</refname> - <refpurpose> - Find position of first occurrence of a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strpos</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - <paramdef>int - <parameter><optional>offset</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns the numeric position of the first occurrence of - <parameter>needle</parameter> in the - <parameter>haystack</parameter> string. Unlike the - <function>strrpos</function>, this function can take a full - string as the <parameter>needle</parameter> parameter and the - entire string will be used. - </para> - <para> - If <parameter>needle</parameter> is not found, returns false. - <note> - <para> - It is easy to mistake the return values for "character found at - position 0" and "character not found". Here's how to detect - the difference: - <informalexample> - <programlisting role="php"> -// in PHP 4.0b3 and newer: -$pos = strpos ($mystring, "b"); -if ($pos === false) { // note: three equal signs - // not found... -} - -// in versions older than 4.0b3: -$pos = strpos ($mystring, "b"); -if (is_string ($pos) &amp;&amp; !$pos) { - // not found... -} - </programlisting> - </informalexample> - </para> - </note> - </para> - <para> - If <parameter>needle</parameter> is not a string, it is converted - to an integer and applied as the ordinal value of a character. - </para> - <para> - The optional <parameter>offset</parameter> parameter allows you - to specify which character in <parameter>haystack</parameter> to - start searching. The position returned is still relative to the - the beginning of <parameter>haystack</parameter>. - </para> - <para> - See also <function>strrpos</function>, - <function>strrchr</function>, <function>substr</function>, - <function>stristr</function>, and <function>strstr</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strrchr"> - <refnamediv> - <refname>strrchr</refname> - <refpurpose> - Find the last occurrence of a character in a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strrchr</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function returns the portion of - <parameter>haystack</parameter> which starts at the last - occurrence of <parameter>needle</parameter> and goes until the - end of <parameter>haystack</parameter>. - </para> - <para> - Returns false if <parameter>needle</parameter> is not found. - </para> - <para> - If <parameter>needle</parameter> contains more than one - character, the first is used. - </para> - <para> - If <parameter>needle</parameter> is not a string, it is converted - to an integer and applied as the ordinal value of a character. - <example> - <title><function>Strrchr</function> example</title> - <programlisting role="php"> -// get last directory in $PATH -$dir = substr (strrchr ($PATH, ":"), 1); - -// get everything after last newline -$text = "Line 1\nLine 2\nLine 3"; -$last = substr (strrchr ($text, 10), 1 ); - </programlisting> - </example> - </para> - <para> - See also <function>substr</function>, - <function>stristr</function>, and <function>strstr</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.str-repeat"> - <refnamediv> - <refname>str_repeat</refname> - <refpurpose>Repeat a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>str_repeat</function></funcdef> - <paramdef>string <parameter>input</parameter></paramdef> - <paramdef>int <parameter>multiplier</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns <parameter>input_str</parameter> repeated - <parameter>multiplier</parameter> times. - <parameter>multiplier</parameter> has to be greater than 0. - </para> - <example> - <title><function>Str_repeat</function> example</title> - <programlisting role="php"> -echo str_repeat ("-=", 10); - </programlisting> - </example> - <para> - This will output "-=-=-=-=-=-=-=-=-=-=". - </para> - <note> - <para> - This function was added in PHP 4.0. - </para> - </note> - </refsect1> - </refentry> - - <refentry id="function.strrev"> - <refnamediv> - <refname>strrev</refname> - <refpurpose>Reverse a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strrev</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns <parameter>string</parameter>, reversed. - </para> - </refsect1> - </refentry> - - <refentry id="function.strrpos"> - <refnamediv> - <refname>strrpos</refname> - <refpurpose> - Find position of last occurrence of a char in a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strrpos</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>char <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns the numeric position of the last occurrence of - <parameter>needle</parameter> in the - <parameter>haystack</parameter> string. Note that the needle in - this case can only be a single character. If a string is passed - as the needle, then only the first character of that string will - be used. - </para> - <para> - If <parameter>needle</parameter> is not found, returns false. - </para> - <para> - If <parameter>needle</parameter> is not a string, it is converted - to an integer and applied as the ordinal value of a character. - </para> - <para> - See also <function>strpos</function>, - <function>strrchr</function>, <function>substr</function>, - <function>stristr</function>, and <function>strstr</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strspn"> - <refnamediv> - <refname>strspn</refname> - <refpurpose> - Find length of initial segment matching mask - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strspn</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - Returns the length of the initial segment of - <parameter>str1</parameter> which consists entirely of characters - in <parameter>str2</parameter>. - </simpara> - <para> - <informalexample> - <programlisting role="php"> -strspn ("42 is the answer, what is the question ...", "1234567890"); - </programlisting> - <para> - will return 2 as result. - </para> - </informalexample> - </para> - <simpara> - See also <function>strcspn</function>. - </simpara> - </refsect1> - </refentry> - - <refentry id="function.strstr"> - <refnamediv> - <refname>strstr</refname> - <refpurpose>Find first occurrence of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strstr</function></funcdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns all of <parameter>haystack</parameter> from the first - occurrence of <parameter>needle</parameter> to the end. - </para> - <para> - If <parameter>needle</parameter> is not found, returns false. - </para> - <para> - If <parameter>needle</parameter> is not a string, it is converted - to an integer and applied as the ordinal value of a character. - </para> - <para> - <note> - <para> - Note that this function is case-sensitive. For - case-insensitive searches, use <function>stristr</function>. - </para> - </note> - </para> - <para> - <example> - <title><function>Strstr</function> example</title> - <programlisting role="php"> -$email = 'sterling@designmultimedia.com'; -$domain = strstr ($email, '@'); -print $domain; // prints @designmultimedia.com - </programlisting> - </example> - </para> - <para> - See also <function>stristr</function>, - <function>strrchr</function>, <function>substr</function>, and - <function>ereg</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strtok"> - <refnamediv> - <refname>strtok</refname> - <refpurpose>Tokenize string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strtok</function></funcdef> - <paramdef>string <parameter>arg1</parameter></paramdef> - <paramdef>string <parameter>arg2</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - <function>strtok</function> is used to tokenize a string. That - is, if you have a string like "This is an example string" you - could tokenize this string into its individual words by using the - space character as the token. - <example> - <title><function>Strtok</function> example</title> - <programlisting role="php"> -$string = "This is an example string"; -$tok = strtok ($string," "); -while ($tok) { - echo "Word=$tok&lt;br>"; - $tok = strtok (" "); -} - </programlisting> - </example> - </para> - <para> - Note that only the first call to strtok uses the string argument. - Every subsequent call to strtok only needs the token to use, as - it keeps track of where it is in the current string. To start - over, or to tokenize a new string you simply call strtok with the - string argument again to initialize it. Note that you may put - multiple tokens in the token parameter. The string will be - tokenized when any one of the characters in the argument are - found. - </para> - <para> - Also be careful that your tokens may be equal to "0". This - evaluates to false in conditional expressions. - </para> - <para> - See also <function>split</function> and - <function>explode</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strtolower"> - <refnamediv> - <refname>strtolower</refname> - <refpurpose>Make a string lowercase</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strtolower</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns <parameter>string</parameter> with all alphabetic - characters converted to lowercase. - </para> - <para> - Note that 'alphabetic' is determined by the current locale. This - means that in i.e. the default "C" locale, characters such as - umlaut-A (Ä) will not be converted. - </para> - <example> - <title><function>Strtolower</function> example</title> - <programlisting role="php"> -$str = "Mary Had A Little Lamb and She LOVED It So"; -$str = strtolower($str); -print $str; # Prints mary had a little lamb and she loved it so - </programlisting> - </example> - <para> - See also <function>strtoupper</function> - and <function>ucfirst</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strtoupper"> - <refnamediv> - <refname>strtoupper</refname> - <refpurpose>Make a string uppercase</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strtoupper</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Returns <parameter>string</parameter> with all alphabetic - characters converted to uppercase. - </para> - <para> - Note that 'alphabetic' is determined by the current locale. For - instance, in the default "C" locale characters such as umlaut-a - (ä) will not be converted. - </para> - <example> - <title><function>Strtoupper</function> example</title> - <programlisting role="php"> -$str = "Mary Had A Little Lamb and She LOVED It So"; -$str = strtoupper ($str); -print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO - </programlisting> - </example> - <para> - See also <function>strtolower</function> - and <function>ucfirst</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.str-replace"> - <refnamediv> - <refname>str_replace</refname> - <refpurpose> - Replace all occurrences of needle in haystack with str - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>str_replace</function></funcdef> - <paramdef>string <parameter>needle</parameter></paramdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string <parameter>haystack</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function replaces all occurences of - <parameter>needle</parameter> in <parameter>haystack</parameter> - with the given <parameter>str</parameter>. If you don't need - fancy replacing rules, you should always use this function - instead of <function>ereg_replace</function>.</para> - <para> - <example> - <title><function>Str_replace</function> example</title> - <programlisting role="php"> -$bodytag = str_replace ("%body%", "black", "&lt;body text=%body%>"); - </programlisting> - </example> - </para> - <para> - This function is binary safe. - </para> - <note> - <para> - <function>Str_replace</function> was added in PHP 3.0.6, but was - buggy up until PHP 3.0.8. - </para> - </note> - <para> - See also <function>ereg_replace</function> and - <function>strtr</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.strtr"> - <refnamediv> - <refname>strtr</refname> - <refpurpose>Translate certain characters</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>strtr</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>string <parameter>from</parameter></paramdef> - <paramdef>string <parameter>to</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function operates on <parameter>str</parameter>, translating - all occurrences of each character in <parameter>from</parameter> - to the corresponding character in <parameter>to</parameter> and - returning the result. - </para> - <para> - If <parameter>from</parameter> and <parameter>to</parameter> are - different lengths, the extra characters in the longer of the two - are ignored. - <example> - <title><function>Strtr</function> example</title> - <programlisting role="php"> -$addr = strtr($addr, "äåö", "aao"); - </programlisting> - </example> - </para> - <para> - <function>strtr</function> can be called with only two - arguments. If called with two arguments it behaves in a new way: - <parameter>from</parameter> then has to be an array that contains - string -> string pairs that will be replaced in the source - string. <function>strtr</function> will always look for the - longest possible match first and will *NOT* try to replace stuff - that it has already worked on. - </para> - <para> - Examples: - <informalexample> - <programlisting role="php"> -$trans = array ("hello" =&gt; "hi", "hi" =&gt; "hello"); -echo strtr("hi all, I said hello", $trans) . "\n"; - </programlisting> - </informalexample> - This will show: "hello all, I said hi", - </para> - <note> - <simpara> - This feature (two arguments) was added in PHP 4.0. - </simpara> - </note> - <para> - See also <function>ereg_replace</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.substr"> - <refnamediv> - <refname>substr</refname> - <refpurpose>Return part of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>substr</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - <paramdef>int <parameter>start</parameter></paramdef> - <paramdef>int - <parameter><optional>length</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Substr returns the portion of <parameter>string</parameter> - specified by the <parameter>start</parameter> and - <parameter>length</parameter> parameters. - </para> - <para> - If <parameter>start</parameter> is positive, the returned string - will start at the <parameter>start</parameter>'th character of - <parameter>string</parameter>. - </para> - <para> - Examples: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1); // returns "bcdef" -$rest = substr ("abcdef", 1, 3); // returns "bcd" - </programlisting> - </informalexample> - </para> - <para> - If <parameter>start</parameter> is negative, the returned string - will start at the <parameter>start</parameter>'th character - from the end of <parameter>string</parameter>.</para> - <para> - Examples: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", -1); // returns "f" -$rest = substr ("abcdef", -2); // returns "ef" -$rest = substr ("abcdef", -3, 1); // returns "d" - </programlisting> - </informalexample> - </para> - <para> - If <parameter>length</parameter> is given and is positive, the - string returned will end <parameter>length</parameter> characters - from <parameter>start</parameter>. If this would result in a - string with negative length (because the start is past the end of - the string), then the returned string will contain the single - character at <parameter>start</parameter>. - </para> - <para> - If <parameter>length</parameter> is given and is negative, the - string returned will end <parameter>length</parameter> characters - from the end of <parameter>string</parameter>. If this would - result in a string with negative length, then the returned string - will contain the single character at - <parameter>start</parameter>. - </para> - <para> - Examples: - <informalexample> - <programlisting role="php"> -$rest = substr ("abcdef", 1, -1); // returns "bcde" - </programlisting> - </informalexample> - </para> - <para> - See also <function>strrchr</function> and - <function>ereg</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.substr-count"> - <refnamediv> - <refname>substr_count</refname> - <refpurpose>Count the number of substring occurrences</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>substr_count</function></funcdef> - <paramdef>string <parameter>haystrack</parameter></paramdef> - <paramdef>string <parameter>needle</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - <function>substr_count</function> returns the number of times the - <parameter>needle</parameter> substring occurs in the - <parameter>haystack</parameter> string. - </para> - - <para> - <example> - <title><function>substr_count</function> example</title> - <programlisting> -print substr_count("This is a test", "is"); // prints out 2 - </programlisting> - </example> - </para> - </refsect1> - </refentry> - - <refentry id="function.substr-replace"> - <refnamediv> - <refname>substr_replace</refname> - <refpurpose>Replace text within a portion of a string</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>substr_replace</function></funcdef> - <paramdef>string <parameter>string</parameter></paramdef> - <paramdef>string <parameter>replacement</parameter></paramdef> - <paramdef>int <parameter>start</parameter></paramdef> - <paramdef>int - <parameter><optional>length</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - <function>substr_replace</function> replaces the part of - <parameter>string</parameter> delimited by the - <parameter>start</parameter> and (optionally) - <parameter>length</parameter> parameters with the string given in - <parameter>replacement</parameter>. The result is returned. - </para> - <para> - If <parameter>start</parameter> is positive, the replacing will - begin at the <parameter>start</parameter>'th offset into - <parameter>string</parameter>. - </para> - <para> - If <parameter>start</parameter> is negative, the replacing will - begin at the <parameter>start</parameter>'th character from the - end of <parameter>string</parameter>. - </para> - <para> - If <parameter>length</parameter> is given and is positive, it - represents the length of the portion of - <parameter>string</parameter> which is to be replaced. If it is - negative, it represents the number of characters from the end of - <parameter>string</parameter> at which to stop replacing. If it - is not given, then it will default to strlen( - <parameter>string</parameter> ); i.e. end the replacing at the - end of <parameter>string</parameter>. - </para> - <para> - <example> - <title><function>Substr_replace</function> example</title> - <programlisting role="php"> -&lt;?php -$var = 'ABCDEFGH:/MNRPQR/'; -echo "Original: $var&lt;hr&gt;\n"; - -/* These two examples replace all of $var with 'bob'. */ -echo substr_replace ($var, 'bob', 0) . "&lt;br&gt;\n"; -echo substr_replace ($var, 'bob', 0, strlen ($var)) . "&lt;br&gt;\n"; - -/* Insert 'bob' right at the beginning of $var. */ -echo substr_replace ($var, 'bob', 0, 0) . "&lt;br&gt;\n"; - -/* These next two replace 'MNRPQR' in $var with 'bob'. */ -echo substr_replace ($var, 'bob', 10, -1) . "&lt;br&gt;\n"; -echo substr_replace ($var, 'bob', -7, -1) . "&lt;br&gt;\n"; - -/* Delete 'MNRPQR' from $var. */ -echo substr_replace ($var, '', 10, -1) . "&lt;br&gt;\n"; -?&gt; - </programlisting> - </example> - </para> - <para> - See also <function>str_replace</function> and - <function>substr</function>. - </para> - <note> - <simpara> - <function>Substr_replace</function> was added in PHP 4.0. - </simpara> - </note> - </refsect1> - </refentry> - - <refentry id="function.trim"> - <refnamediv> - <refname>trim</refname> - <refpurpose> - Strip whitespace from the beginning and end of a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>trim</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function strips whitespace from the start and the end of a - string and returns the stripped string. The whitespace - characters it currently strips are: "\n", "\r", "\t", "\v", "\0", - and a plain space. - </para> - <para> - See also <function>chop</function> and - <function>ltrim</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.ucfirst"> - <refnamediv> - <refname>ucfirst</refname> - <refpurpose>Make a string's first character uppercase</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>ucfirst</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Capitalizes the first character of <parameter>str</parameter> if - that character is alphabetic. - </para> - <para> - Note that 'alphabetic' is determined by the current locale. For - instance, in the default "C" locale characters such as umlaut-a - (ä) will not be converted. - <example> - <title><function>Ucfirst</function> example</title> - <programlisting role="php"> -$text = 'mary had a little lamb and she loved it so.'; -$text = ucfirst ($text); // $text is now Mary had a little lamb - // and she loved it so. - </programlisting> - </example> - </para> - <para> - See also <function>strtoupper</function> and - <function>strtolower</function>. - </para> - </refsect1> - </refentry> - - <refentry id="function.ucwords"> - <refnamediv> - <refname>ucwords</refname> - <refpurpose> - Uppercase the first character of each word in a string - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>ucwords</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - Capitalizes the first character of each word in - <parameter>str</parameter> if that character is alphabetic. - <example> - <title><function>ucwords</function> example</title> - <programlisting role="php"> -$text = "mary had a little lamb and she loved it so."; -$text = ucwords($text); // $text is now: Mary Had A Little - // Lamb And She Loved It So. - </programlisting> - </example> - </para> - <para> - See also <function>strtoupper</function>, - <function>strtolower</function> and <function>ucfirst</function>. - </para> - </refsect1> - </refentry> - - - <refentry id="function.wordwrap"> - <refnamediv> - <refname>wordwrap</refname> - <refpurpose> - Wraps a string to a given number of characters using a string - break character. - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>wordwrap</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - <paramdef>int - <parameter><optional>width</optional></parameter> - </paramdef> - <paramdef>string - <parameter><optional>break</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - <para> - Wraps the string <parameter>str</parameter> at the column number - specified by the (optional) <parameter>width</parameter> - parameter. The line is broken using the (optional) - <parameter>break</parameter> parameter. - </para> - <para> - <function>wordwrap</function> will automatically wrap at column - 75 and break using '\n' (newline) if <parameter>width</parameter> - or <parameter>break</parameter> are not given. - </para> - <para> - <example> - <title><function>wordwrap</function> example</title> - <programlisting role="php"> -$text = "The quick brown fox jumped over the lazy dog."; -$newtext = wordwrap( $text, 20 ); - -echo "$newtext\n"; - </programlisting> - </example> - </para> - <para> - This example would display: - </para> - <para> - <informalexample> - <programlisting> -The quick brown fox - jumped over the lazy dog. - </programlisting> - </informalexample> - </para> - <para> - See also <function>nl2br</function>. - </para> - </refsect1> - </refentry> - - - </reference> - -<!-- 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 -sgml-parent-document:nil -sgml-default-dtd-file:"../../manual.ced" -sgml-exposed-tags:nil -sgml-local-catalogs:nil -sgml-local-ecat-files:nil -End: ---> +<reference id="ref.strings"> + <title>Funciones de cadenas</title> + <titleabbrev>Cadenas</titleabbrev> + + <partintro> + <simpara> + Todas estas funciones manipulan cadenas de varias maneras. En las + secciones sobre expresiones regulares y manejo de URL se pueden + encontrar secciones más especializadas. + </simpara> + </partintro> + + <refentry id="function.addcslashes"> + <refnamediv> + <refname>AddCSlashes</refname> + <refpurpose>Marca una cadena con barras al estilo del C</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>addcslashes</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string <parameter>listcar</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena con barras invertidas antes de los caracteres + listados en el parámetro <parameter>listcar</parameter>. También + marca <literal>\n</literal>, <literal>\r</literal> etc. Al estilo + del C, los caracteres con códico ASCII inferior a 32 y superior a + 126 son convertidos a representación octal. Tenga cuidado cuando + marque caracteres alfanuméricos. Puede especificar un rango en + <parameter>listcar</parameter> como el "\0..\37", que marcaría + todos los caracteres con código ASCII entre 0 y 31. + <example> + <title>Ejemplo de <function>Addcslashes</function></title> + <programlisting role="php"> +$tradformado = addcslashes ($no_transf, "\0..\37!@\177..\377"); + </programlisting> + </example> + <note> + <simpara> + Añadida en PHP4b3-dev.</simpara> + </note> + </para> + <para> + Vea también <function>stripcslashes</function>, + <function>stripslashes</function>, + <function>htmlspecialchars</function>, + <function>htmlspecialchars</function>, y + <function>quotemeta</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.addslashes"> + <refnamediv> + <refname>AddSlashes</refname> + <refpurpose>Marca una cadena con barras</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>addslashes</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena con barras invertidas frente a los caracteres + que necesitan marcarse en consultas de bases de datos, etc. Estos + son la comilla simple (<literal>'</literal>), comilla doble + (<literal>"</literal>), barra invertida (<literal>\</literal>) + y NUL (el byte nulo). + </para> + <para> + Vea también <function>stripslashes</function>, + <function>htmlspecialchars</function>, y + <function>quotemeta</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.bin2hex"> + <refnamediv> + <refname>bin2hex</refname> + <refpurpose> + Convierte datos binarios en su representación hexadecimal + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>bin2hex</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena ASCII que contiene la representación hexadecimal + de <parameter>cad</parameter>. La conversión se realiza byte a byte, + con los 4 bits superiores primero. + </para> + </refsect1> + </refentry> + + <refentry id="function.chop"> + <refnamediv> + <refname>Chop</refname> + <refpurpose>Elimina espacios sobrantes al final</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>chop</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la cadena argumento sin los espacios sobrantes, + incluyendo los saltos de línea. + <example> + <title>Ejemplo de <function>Chop</function></title> + <programlisting role="php"> +$recortada = chop ($linea); + </programlisting> + </example> + </para> + <para> + Vea también <function>trim</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.chr"> + <refnamediv> + <refname>Chr</refname> + <refpurpose>Devuelve un caracter específico</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>chr</function></funcdef> + <paramdef>int <parameter>ascii</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena de un caracter que congiene el caracter + especificado por <parameter>ascii</parameter>. + <example> + <title>Ejemplo de <function>Chr</function></title> + <programlisting role="php"> +$cad .= chr (27); /* añade un caracter de escape al final de $cad */ + +/* A veces esto es más útil */ + +$cad = sprintf ("La cadena termina en escape: %c", 27); + </programlisting> + </example> + Esta función complementa a <function>ord</function>. Vea también + <function>sprintf</function> con una cadena de formato + <literal>%c</literal>. + </para> + </refsect1> + </refentry> + + <refentry id="function.chunk-split"> + <refnamediv> + <refname>chunk_split</refname> + <refpurpose>Divide una cadena en trozos más pequeños</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>chunk_split</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + <paramdef>int + <parameter><optional>tamatrozo</optional></parameter> + </paramdef> + <paramdef>string + <parameter><optional>final</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Se puede utilizar para trocear una cadena en pedazos más pequeños, + lo que es útil, p.ej., para convertir la salida de la función <link + linkend="function.base64-encode">base64_encode</link> a la semántica + del RFC 2045. Inserta la cadena <parameter>final</parameter> cada + <parameter>tamatrozo</parameter> (por defecto vale 76) caracteres. + Devuelve la nueva cadena y deja intacta la original. + <example> + <title>Ejemplo de <function>Chunk_split</function></title> + <programlisting role="php"> +# formatear $datos usando la semántica del RFC 2045 + +$nueva_cad = chunk_split (base64_encode($datos)); + </programlisting> + </example> + Esta función es notablemente más rápida que + <function>ereg_replace</function>. + <note> + <para> + Esta función se añadió en la 3.0.6. + </para> + </note> + </para> + </refsect1> + </refentry> + + <refentry id="function.convert-cyr-string"> + <refnamediv> + <refname>convert_cyr_string</refname> + <refpurpose> + Convierte de un juego de caracteres Cirílico a otro + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>convert_cyr_string</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string <parameter>desde</parameter></paramdef> + <paramdef>string <parameter>hasta</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función convierte la cadena dada de un juego de caracteres + Cirílico a otro. Los argumentos <parameter>desde</parameter> y + <parameter>hasta</parameter> son caracteres sencillos que + representan los juegos de caracteres Cirílicos fuente y destino. + Los tipos soportados son: + <itemizedlist> + <listitem> + <simpara> + k - koi8-r + </simpara> + </listitem> + <listitem> + <simpara> + w - windows-1251 + </simpara> + </listitem> + <listitem> + <simpara> + i - iso8859-5 + </simpara> + </listitem> + <listitem> + <simpara> + a - x-cp866 + </simpara> + </listitem> + <listitem> + <simpara> + d - x-cp866 + </simpara> + </listitem> + <listitem> + <simpara> + m - x-mac-cyrillic + </simpara> + </listitem> + </itemizedlist> + </para> + </refsect1> + </refentry> + + <refentry id="function.count-chars"> + <refnamediv> + <refname>count_chars</refname> + <refpurpose> + Devuelve información sobre los caracteres usados en una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>mixed <function>count_chars</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + <paramdef> + <parameter> + <optional>modo</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Cuenta el número de apariciones de cada valor de byte (0..255) + en <parameter>cadena</parameter> y lo devuelve de varias maneras. + El parámetro opcional <parameter>modo</parameter> vale por defecto + 0. Dependiendo de <parameter>modo</parameter>, + <function>count_chars</function> puede devolver: + <itemizedlist> + <listitem> + <simpara> + 0 - una matriz con el valor del byte como clave y la frecuencia + de cada uno como valor. + </simpara> + </listitem> + <listitem> + <simpara> + 1 - como el 0, pero listando únicamente los valores de byte con + frecuencia superior a cero. + </simpara> + </listitem> + <listitem> + <simpara> + 2 - como el 0, pero listando únicamente los valores de byte con + frecuencia igual a 0. + </simpara> + </listitem> + <listitem> + <simpara> + 3 - se devuelve una cadena que contiene todos los valores de byte + utilizados. + </simpara> + </listitem> + <listitem> + <simpara> + 4 - se devuelve una cadena que contiene todos los valores de byte + no utilizados. + </simpara> + </listitem> + </itemizedlist> + </para> + <note> + <para> + Esta función se añadió en el PHP 4.0. + </para> + </note> + </refsect1> + </refentry> + + <refentry id="function.crc32"> + <refnamediv> + <refname>crc32</refname> + <refpurpose>Calcula el polinomio crc32 de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>crc32</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Genera el polinomio de comprobación de reduncancia cíclica de 32 bits + de <parameter>cad</parameter>. Se suele utilizar para validad la + integridad de los datos transmitidos. + </para> + <para> + Vea también: <function>md5</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.crypt"> + <refnamediv> + <refname>crypt</refname> + <refpurpose>Encripta una cadena mediante DES</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>crypt</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string + <parameter><optional>semilla</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>crypt</function> encriptará una cadena utilizando el + método estándar de encriptación del Unix <abbrev>DES</abbrev>. + Los argumentos son una cadena a encriptar y una cadena semilla + de 2 caracteres en la que basar la encriptación. Vea la página de + manual de Unix sobre crypt para más información. + </para> + <simpara> + Si el argumento de semilla no se proporciona, será generado + aleatoriamente por el PHP. + </simpara> + <simpara> + Algunos sistemas operativos soportan más de un tipo de encriptación. + De hecho, algunas veces la encriptación estándar DES es sustituída + por un algoritmo de encriptación basado en MD5. El tipo de + encriptación es disparado por el argumento semilla. En tiempo de + instalación, el PHP determina la capacidad de la función de + encriptación y aceptará semillas para otros tipos de encriptación. + Si no se proporciona la semilla, el PHP intentará generar una + semilla estándar DES de 2 caraceres por defecto, excepto si el + tipo de encriptación estándar del sistema es el MD5, en cuyo caso + se generará una semilla aleatoria compatible con MD5. El PHP + fija una constante llamada CRYPT_SALT_LENGTH que le especifica si + su sistema soporta una semilla de 2 caracteres o si se debe usar + la semilla de 12 caracteres del NDS. + </simpara> + <simpara> + La función estándar de encriptación <function>crypt</function> contiene + la semilla como los dos primeros caracteres de la salida. + </simpara> + <simpara> + En los sistemas en los que la función crypt() soporta múltiples + tipos de encriptación, las siguienes constantes son fijadas a + 0 ó 1 dependiendo de si está disponible el tipo dado: + </simpara> + <itemizedlist> + <listitem> + <simpara> + CRYPT_STD_DES - Encriptación DES estándar con semilla de 2 caracteres + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_EXT_DES - Encriptación DES extendida con semilla de 9 caracteres + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_MD5 - Encriptación MD5 con semilla de 12 caracteres y comenzando + por $1$ + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_BLOWFISH - Encriptación DES extendida con semilla de 16 caracteres + y comenzando por $2$ + </simpara> + </listitem> + </itemizedlist> + <simpara> + No hay función de desencriptado porque <function>crypt</function> + utiliza un algoritmo de una sola vía. + </simpara> + <simpara> + Vea también: <function>md5</function>. + </simpara> + </refsect1> + </refentry> + <refentry id="function.echo"> + <refnamediv> + <refname>echo</refname> + <refpurpose>Da salida a una o más cadenas</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef><function>echo</function></funcdef> + <paramdef>string <parameter>arg1</parameter></paramdef> + <paramdef>string + <parameter><optional>argn</optional>...</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Da salida a todos sus parámetros. + </simpara> + <para> + <function>Echo</function> no es realmente una función (es una + sentencia del lenguaje) de modo que no se requiere el uso de + los paréntesis. + <example> + <title>Ejemplo de <function>Echo</function></title> + <programlisting role="php"> +echo "Hola Mundo"; + +echo "Esto se extiende +por varias líneas. Los saltos de línea +también se envían"; + +echo "Esto se extiende\npor varias líneas. Los saltos de línea\ntambién se envían"; + </programlisting> + </example> + </para> + <note> + <para> + De hecho, si desea pasar más de un parámetro a echo no debe + encerrarlos entre paréntesis. + </para> + </note> + <simpara> + Vea también: + <function>print</function>, + <function>printf</function>, y + <function>flush</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.explode"> + <refnamediv> + <refname>explode</refname> + <refpurpose>Divide una cadena por otra</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>array <function>explode</function></funcdef> + <paramdef>string <parameter>separador</parameter></paramdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + <paramdef>int + <parameter><optional>limite</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una matriz de cadenas, cada una de las cuales es una + subcadena de <parameter>cadena</parameter> formada mediante su + división en las fronteras marcadas por la cadena + <parameter>separador</parameter>. Si se especifica <parameter>limite</parameter>, + la matriz devuelta contendrá un máximo de <parameter>limite</parameter> + elementos con el último conteniendo el resto de la + <parameter>cadena</parameter>. + </para> + <para> + <example> + <title>Ejemplo de <function>Explode</function></title> + <programlisting role="php"> +$pizza = "trozo1 trozo2 trozo3 trozo4 trozo5 trozo6"; +$trozos = explode (" ", $pizza); + </programlisting> + </example> + </para> + <para> + Vea también <function>split</function> e + <function>implode</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.get-html-translation-table"> + <refnamediv> + <refname>get_html_translation_table</refname> + <refpurpose> + Devuelve la tabla de traducción utilizada por + <function>htmlspecialchars</function> y + <function>htmlentities</function> + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string + <function>get_html_translation_table</function> + </funcdef> + <paramdef>int <parameter>tabla</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>get_html_translation_table</function> devolverá la + tabla de traducción que se usa internamente para + <function>htmlspecialchars</function> y + <function>htmlentities</function>. Hay dos nuevas definiciones + (<parameter>HTML_ENTITIES</parameter>, + <parameter>HTML_SPECIALCHARS</parameter>) que le permiten + especificar la tabla deseada. + <example> + <title>Ejemplo de Tabla de Traducción</title> + <programlisting role="php"> +$trad = get_html_translation_table (HTML_ENTITIES); +$cad = "Hallo &amp; &lt;Frau> &amp; Kr&auml;mer"; +$codif = strtr ($cad, $trad); + </programlisting> + </example> + La variable <literal>$codif</literal> contendrá ahora: "Hallo + &amp;<sgmltag>amp</sgmltag>; + &amp;<sgmltag>lt</sgmltag>;Frau&amp;<sgmltag>gt</sgmltag>; + &amp;<sgmltag>amp</sgmltag>; Kr&amp;<sgmltag>auml</sgmltag>;mer". + </para> + <para> + Lo interesante es usar la función <function>array_flip</function> + para cambiar la dirección de la traducción. + <informalexample> + <programlisting role="php"> +$trad = array_flip ($trad); +$original = strtr ($cad, $trad); + </programlisting> + </informalexample> + El contenido de <literal>$original</literal> sería: "Hallo &amp; + &lt;Frau> &amp; Kr&auml;mer". + <note> + <para> + Esta función fue añadida en PHP 4.0. + </para> + </note> + </para> + <para> + Vea también: <function>htmlspecialchars</function>, + <function>htmlentities</function>, <function>strtr</function>, + y <function>array_flip</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.get-meta-tags"> + <refnamediv> + <refname>get_meta_tags</refname> + <refpurpose> + Extrae todas las etiquetas meta de un archivo y retorna una matriz + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>array <function>get_meta_tags</function></funcdef> + <paramdef>string <parameter>nombrefich</parameter></paramdef> + <paramdef>int + <parameter><optional>use_ruta_include</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Abre el <parameter>nombrefich</parameter> y lo trocea línea a línea + buscando etiquetas &lt;meta> de la forma + <example> + <title>Ejemplo de Etiquetas Meta</title> + <programlisting role="html"> +&lt;meta name="autor" content="nombre"> +&lt;meta name="etiquetas" content="documentación de php3"> +&lt;/head> &lt;!-- el proceso se detiene aquí --> + </programlisting> + </example> + (preste atención a los finales de línea - el PHP utiliza una + función nativa para trocear la entrada, de modo que un archivo + de Mac no funcionará en Unix). + </para> + <para> + El valor de la propiedad name queda como clave y el valor de la + propiedad content queda como el valor de la matriz devuelta, de + modo que pueda usar fácilmente funciones estándar de matrices para + recorrerla o para acceder a valores individuales. Los caracteres + especiales en el valor de name son sustituídos por '_' y el resto + es convertido a minúsculas. + </para> + <para> + Fijando <parameter>use_ruta_include</parameter> a 1 hará que el + PHP intente abrir el archivo a través de la ruta de inclusión. + </para> + </refsect1> + </refentry> + + <refentry id="function.hebrev"> + <refnamediv> + <refname>hebrev</refname> + <refpurpose> + Convierte Hebreo lógico a texto visual + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>hebrev</function></funcdef> + <paramdef>string <parameter>texto_hebreo</parameter></paramdef> + <paramdef>int + <parameter><optional>max_cars_por_linea</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + El parámetro opcional <parameter>max_cars_por_linea</parameter> + indica el máximo número de caracteres que se emitirán por línea. + La función intenta evitar cortar palabras. + </para> + <para> + Vea también <function>hebrevc</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.hebrevc"> + <refnamediv> + <refname>hebrevc</refname> + <refpurpose> + Convierte Hebreo lógico a texto visual con conversión de saltos + de línea + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>hebrevc</function></funcdef> + <paramdef>string <parameter>texto_hebreo</parameter></paramdef> + <paramdef>int + <parameter><optional>max_cars_por_linea</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta funcion es similar a <function>hebrev</function> con la + diferencia que convierte las nuevas líneas (\n) a "&lt;br&gt;\n". + El parámetro opcional <parameter>max_cars_por_linea</parameter> + indica el máximo número de caracteres que se emitirán por línea. + La función intenta evitar cortar palabras. + </para> + <para> + Vea también <function>hebrev</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.htmlentities"> + <refnamediv> + <refname>htmlentities</refname> + <refpurpose> + Convierte todos los caracteres aplicables a entidades HTML + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>htmlentities</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función es del todo idéntica a <function>htmlspecialchars</function>, + excepto que traduce todos los caracteres que tienen equivalente + como entidad HTML. + </para> + <para> + Actualmente se utiliza el juego de caracteres ISO-8859-1. + </para> + <para> + Vea también <function>htmlspecialchars</function> y + <function>nl2br</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.htmlspecialchars"> + <refnamediv> + <refname>htmlspecialchars</refname> + <refpurpose> + Convierte caracteres especiales a entidades HTML + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>htmlspecialchars</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Ciertos caracteres tienen significados especiales en HTML, y deben + ser representados por entidades HTML si se desea preservar su + significado. Esta función devuelve una cadena con dichas conversiones + realizadas. + </para> + <simpara> + Esta función es útil para evitar que el texo entrado por el usuario + contenga marcas HTML, como ocurre en aplicaciones de foros o + libros de visita. + </simpara> + <para> + Actualmente, las traducciones hechas son: + <itemizedlist> + <listitem> + <simpara> + '&amp;' (ampersand) se convierte en '&amp;amp;' + </simpara> + </listitem> + <listitem> + <simpara> + '&quot;' (doble comilla) se convierte en '&amp;quot;' + </simpara> + </listitem> + <listitem> + <simpara> + '&lt;' (menor que) se convierte en '&amp;lt;' + </simpara> + </listitem> + <listitem> + <simpara> + '&gt;' (mayor que) se convierte en '&amp;gt;' + </simpara> + </listitem> + </itemizedlist> + </para> + <para> + Nótese que esta función no traduce nada más que lo mostrado + más arriba. Para una traducción de entidades completa, vea + <function>htmlentities</function>. + </para> + <para> + Vea también <function>htmlentities</function> y + <function>nl2br</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.implode"> + <refnamediv> + <refname>implode</refname> + <refpurpose>Unir elementos de una matriz mediante una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>implode</function></funcdef> + <paramdef>string <parameter>cola</parameter></paramdef> + <paramdef>array <parameter>piezas</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena que contiene una representación de todos los + elementos de la matriz en el mismo orden, pero con la cadena + <parameter>cola</parameter> en medio de los mismos. + <example> + <title>Ejemplo de <function>Implode</function></title> + <programlisting role="php"> +$separada_dospuntos = implode (":", $matrizay); + </programlisting> + </example> + </para> + <simpara> + Vea también <function>explode</function>, <function>join</function>, + y <function>split</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.join"> + <refnamediv> + <refname>join</refname> + <refpurpose>Une elementos de una tabla mediante una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>join</function></funcdef> + <paramdef>string <parameter>cola</parameter></paramdef> + <paramdef>array <parameter>piezas</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <function>join</function> es un alias para + <function>implode</function>, y es idéntica en todo. + </simpara> + <simpara> + Vea también <function>explode</function>, <function>implode</function>, + y <function>split</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.levenshtein"> + <refnamediv> + <refname>levenshtein</refname> + <refpurpose> + Calcula la distancia Levenshtein entre dos cadenas + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>levenshtein</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función devuelve la distancia Levenshtein entre las dos + cadenas argumento, ó -1 si alguna de las cadenas tiene más + de 255 caracteres. + </para> + <para> + La distancia Levenshtein se define como el mínimo número de + caracteres que se tienen que sustituir, insertar o borrar + para transformar <parameter>cad1</parameter> en + <parameter>cad2</parameter>. La complejidad del algoritmo es + <literal>O(m*n)</literal>, donde <literal>n</literal> y + <literal>m</literal> son las longitudes de <parameter>cad1</parameter> + y <parameter>cad2</parameter> (bastante bueno si se la compara con + <function>similar_text</function>, que es O(max(n,m)**3), pero + aún es cara). + </para> + <para> + Vea también <function>soundex</function>, + <function>similar_text</function> y + <function>metaphone</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.ltrim"> + <refnamediv> + <refname>ltrim</refname> + <refpurpose> + Elimina el espacio en blanco del principio de una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ltrim</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función elimina el espacio en blanco del principio de una + cadena y devuelve la cadena resultante. Los caracteres de espacio + que elimina realmente son: "\n", "\r", "\t", "\v", "\0", + y el espacio en sí. + </para> + <para> + Vea también <function>chop</function> y <function>trim</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.md5"> + <refnamediv> + <refname>md5</refname> + <refpurpose>Calcula el hash md5 de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>md5</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Calcula el hash (extracto) MD5 de <parameter>cad</parameter> + usaneo el + <ulink url="&url.rfc;rfc1321.html">Algoritmo de Resumen de + Mensajes MD5 de RSA Data Security, Inc. </ulink>. + </para> + <para> + Vea también: <function>crc32</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.metaphone"> + <refnamediv> + <refname>Metaphone</refname> + <refpurpose>Calcula la clave "metáfona" de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>metaphone</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Calcula la clave "metáfona" de <parameter>cad</parameter>. + </para> + <para> + Similarmente a <function>soundex</function>, metaphone crea la + misma clave para palabras que suenan parecidas. Es más precisa + que la función <function>soundex</function>, pues conoce las + reglas básicas de la pronunciación del Inglés. Las claves + metafónicas generadas son de longitud variable. + </para> + <para> + Metaphone fue desarrollado por Lawrence Philips + &lt;lphilips@verity.com>. Se describe en ["Practical + Algorithms for Programmers", Binstock &amp; Rex, Addison Wesley, + 1995]. + <note> + <para> + Esta función se añadió en PHP 4.0. + </para> + </note> + </para> + </refsect1> + </refentry> + + <refentry id="function.nl2br"> + <refnamediv> + <refname>nl2br</refname> + <refpurpose>Convierte nuevas líneas a saltos de línea HTML</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>nl2br</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la <parameter>cadena</parameter> con '&lt;BR&gt;' insertados + antes de cada nueva línea. + </para> + <para> + Vea también <function>htmlspecialchars</function>, + <function>htmlentities</function> y + <function>wordwrap</function>. + </para> + </refsect1> + </refentry> + <refentry id="function.ord"> + <refnamediv> + <refname>Ord</refname> + <refpurpose>Devuelve el valor ASCII de un caracter</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>ord</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve el valor ASCII del primer caracter de + <parameter>cadena</parameter>. Esta función complementa a + <function>chr</function>. + <example> + <title>Ejemplo de <function>Ord</function></title> + <programlisting role="php"> +if (ord ($cad) == 10) { + echo "El primer caracter de \$cad es un salto de línea.\n"; +} + </programlisting> + </example> + </para> + <simpara> + Vea también <function>chr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.parse-str"> + <refnamediv> + <refname>parse_str</refname> + <refpurpose>Divide la cadena en variables</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>parse_str</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Divide <parameter>cad</parameter> como si fuera la cadena de consulta + enviada por un URL y crea las variables en el ámbito actual. + </para> + <para> + <example> + <title>Usando <function>parse_str</function></title> + <programlisting role="php"> +$cad = "primero=valor&amp;segundo[]=esto+funciona&amp;segundo[]=otro"; +parse_str($cad); +echo $primero; /* escribe "valor" */ +echo $segundo[0]; /* escribe "esto funciona" */ +echo $segundo[1]; /* escribe "otro" */ + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="function.print"> + <refnamediv> + <refname>print</refname> + <refpurpose>Emite una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef><function>print</function></funcdef> + <paramdef>string <parameter>arg</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Emite <parameter>arg</parameter>. + </simpara> + <simpara> + Vea también: <function>echo</function>, <function>printf</function>, + y <function>flush</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.printf"> + <refnamediv> + <refname>printf</refname> + <refpurpose>Emite una cadena con formato</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>printf</function></funcdef> + <paramdef>string <parameter>formato</parameter></paramdef> + <paramdef>mixed + <parameter><optional>args</optional></parameter>... + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Produce una salida según el <parameter>formato</parameter>, que es + descrito en la documentación para <function>sprintf</function>. + </simpara> + <simpara> + Vea también: <function>print</function>, <function>sprintf</function>, + <function>sscanf</function>, <function>fscanf</function>, + y <function>flush</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.quoted-printable-decode"> + <refnamediv> + <refname>quoted_printable_decode</refname> + <refpurpose> + Convierte una cadena con marcación imprimible a una cadena de 8 bits + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string + <function>quoted_printable_decode</function> + </funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Esta función devuelve una cadena binaria de 8 bit que se corresponde + con la cadena con marcación imprimible decodificada. Esta función es + similar a <function>imap_qprint</function>, pero sin requerir que el + módulo IMAP funcione. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.quotemeta"> + <refnamediv> + <refname>quotemeta</refname> + <refpurpose>Quote meta characters</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>quotemeta</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una versión de la cadena con una barra invertida + (<literal>\</literal>) antes de cada caracter de este + conjunto: <screen>. \\ + * ? [ ^ ] ( $ )</screen> + </para> + <simpara> + Vea también <function>addslashes</function>, + <function>htmlentities</function>, + <function>htmlspecialchars</function>, + <function>nl2br</function>, y + <function>stripslashes</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.rtrim"> + <refnamediv> + <refname>rtrim</refname> + <refpurpose>Elimina espacios en blanco al final de la cadena.</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcdef>string <function>rtrim</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcsynopsis> + <para> + Devuelve la cadena argumento sin espacios en blanco ni saltos + de línea al final. Es un alias para <function>chop</function>. + <example> + <title>Ejemplo de <function>rtrim</function></title> + <programlisting role="php"> +$recortada = rtrim ($linea); + </programlisting> + </example> + </para> + <para> + Vea también <function>trim</function>, <function>ltrim</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.sscanf"> + <refnamediv> + <refname>sscanf</refname> + <refpurpose>Trocea la entrada desde una cadena según un formato dado</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>mixed <function>sscanf</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string <parameter>formato</parameter></paramdef> + <paramdef>string + <parameter><optional>var1</optional></parameter>... + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + La función<function>sscanf</function> es la función de entrada análoga + de <function>printf</function>. <function>sscanf</function> lee del + parámetro de cadena <parameter>cad</parameter> y lo interpreta según el + <parameter>formato</parameter> especificado. Si sólo se pasan dos parámetros + a esta función, los valores devueltos se harán en una matriz. + <example> + <title>Ejemplo de <function>sscanf</function></title> + <programlisting role="php"> +// obteniendo el número de serie +$numserie = sscanf("SN/2350001","SN/%d"); +// y la fecha de fabricación +$fecha = "01 Enero 2000"; +list($dia, $mes, $anno) = sscanf($fecha,"%d %s %d"); +echo "El objeto $numserie fue fabricado el: $anno-".substr($mes,0,3)."-$dia\n"; + </programlisting> + </example> + Si se pasan los parámetros opcionales, la función devolverá el número de + valores asignados. Los parámetros opcionales deben ser pasados por + referencia. + <example> + <title>Ejemplo de <function>sscanf</function> - usando parámetros opcionales</title> + <programlisting role="php"> +// obtener autor y generar la ficha DocBook +$autor = "24\tLewis Carroll"; +$n = sscanf($autor,"%d\t%s %s", &amp;$id, &amp;$nombre, &amp;$apell); +echo "&lt;autor id='$id'&gt; + &lt;firstname&gt;$nombre&lt;/firstname&gt; + &lt;surname&gt;$apell&lt;/surname&gt; +&lt;/author&gt;\n"; + </programlisting> + </example> + </para> + <para> + Vea también: <function>fscanf</function>, <function>printf</function>, + y <function>sprintf</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.setlocale"> + <refnamediv> + <refname>setlocale</refname> + <refpurpose>Fija la información de localidad</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>setlocale</function></funcdef> + <paramdef>string <parameter>categoria</parameter></paramdef> + <paramdef>string <parameter>localidad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>categoria</parameter> es una cadena que especifica + la categoría de las funciones afectadas por el ajuste de localidad: + <itemizedlist> + <listitem> + <simpara> + LC_ALL para todas las funciones + </simpara> + </listitem> + <listitem> + <simpara> + LC_COLLATE para la comparación de cadenas - aún no incluída en el PHP + </simpara> + </listitem> + <listitem> + <simpara> + LC_CTYPE para la conversión y clasificación de caracteres, como por + ejemplo <function>strtoupper</function> + </simpara> + </listitem> + <listitem> + <simpara> + LC_MONETARY para localeconv() - aún no incluída en el PHP + </simpara> + </listitem> + <listitem> + <simpara> + LC_NUMERIC para el separador decimal + </simpara> + </listitem> + <listitem> + <simpara> + LC_TIME para el formato de fecha y hora con + <function>strftime</function> + </simpara> + </listitem> + </itemizedlist> + </para> + <para> + Si <parameter>localidad</parameter> es la cadena vacía + <literal>""</literal>, los nombres de localidad se fijarán a + partir de las variables de entorno con los mismos nombres de las + categorías anteriores, o desde "LANG". + </para> + <para> + Si la localidad es cero o <literal>"0"</literal>, el ajuste de + localidad no se ve afectado y sólo se devuelve el ajuste actual. + </para> + <para> + setlocale devuelve la nueva localidad, o false si la funcionalidad + de localización no está disponible en la plataforma, la localidad + especificada no existe o el nombre de categoría no es válido. + Un nombre de categoría no válido también produce un mensaje de + aviso. + </para> + </refsect1> + </refentry> + + <refentry id="function.similar-text"> + <refnamediv> + <refname>similar_text</refname> + <refpurpose> + Calcula la similitud entre dos cadenas + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>similar_text</function></funcdef> + <paramdef>string <parameter>primera</parameter></paramdef> + <paramdef>string <parameter>segunda</parameter></paramdef> + <paramdef>double + <parameter><optional>porcentaje</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función calcula la similitud entre dos cadenas según se describe + en Oliver [1993]. Nótese que esta implementación no utiliza una pila + como en el pseudo-código de Oliver, sino llamadas recursivas que pueden + o no acelerar el proceso completo. Nótese también que la complejidad + de este algoritmo es O(N**3), donde N es la longitud de la cadena + más larga. + </para> + <para> + Pasando una referencia como tercer argumento, + <function>similar_text</function> calculará para usted la similitud + como porcentaje. Devuelve el número de caracteres coincidentes en + ambas cadenas. + </para> + </refsect1> + </refentry> + + <refentry id="function.soundex"> + <refnamediv> + <refname>soundex</refname> + <refpurpose>Calcula la clave soundex de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>soundex</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Calcula la clave soundex de <parameter>cad</parameter>. + </para> + <para> + Las claves soundex tienen la propiedad de que las palabras que + se pronuncian de forma parecida tienen la misma clave, de modo + que se pueden usar para simplificar la búsqueda en las bases de + datos cuando se conoce la pronunciación pero no la transcripción. + Esta función soundex devuelve una cadena de 4 caracteres que + comienza por una letra. + </para> + <para> + Esta función soundex en particular es la descrita por Donald Knuth + en "The Art Of Computer Programming, vol. 3: Sorting And + Searching", Addison-Wesley (1973), pp. 391-392. + </para> + <para> + <example> + <title>Ejemplos de Soundex</title> + <programlisting role="php"> +soundex ("Euler") == soundex ("Ellery") == 'E460'; +soundex ("Gauss") == soundex ("Ghosh") == 'G200'; +soundex ("Knuth") == soundex ("Kant") == 'H416'; +soundex ("Lloyd") == soundex ("Ladd") == 'L300'; +soundex ("Lukasiewicz") == soundex ("Lissajous") == 'L222'; + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="function.sprintf"> + <refnamediv> + <refname>sprintf</refname> + <refpurpose>Devuelve una cadena con formato</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>sprintf</function></funcdef> + <paramdef>string <parameter>formato</parameter></paramdef> + <paramdef>mixed + <parameter><optional>args</optional></parameter>... + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Devuelve una cadena producida de acuerdo a la cadena de + <parameter>formato</parameter>. + </simpara> + <simpara> + La cadena de formato está compuesta por cero o más directivas: + caracteres ordinarios (excepto <literal>%</literal>) que son + copiados directamente al resultado, y <emphasis>especificaciones + de conversión</emphasis>, cada una de las cuales provoca la + obtención de su propio parámetro. Esto se aplica tanto a + <function>sprintf</function> como a <function>printf</function>. + </simpara> + <para> + Cada especificación de conversión consiste en uno de estos elementos, + por orden: + <orderedlist> + <listitem> + <simpara> + Un <emphasis>especificador de relleno</emphasis> opcional que + indica qué caracter se utilizará para rellenar el resultado hasta + el tamaño de cadena correcto. Este puede ser un espacio o un + <literal>0</literal> (caracter cero). El valor por defecto es + rellenar con espacios. Un caracter de relleno alternativo se puede + especificar prefijándolo con una comilla simple (<literal>'</literal>). + Vea los ejemplos más abajo. + </simpara> + </listitem> + <listitem> + <simpara> + Un <emphasis>especificador de alineación</emphasis> opcional que + indica si el resultado debe ser alineado a la izquierda o a la + derecha. Por defecto se alinea a la derecha; un caracter + <literal>-</literal> aquí lo justificará a la izquierda. + </simpara> + </listitem> + <listitem> + <simpara> + Un número opcional, un <emphasis>especificador de ancho</emphasis> + que dice el número de caracteres (mínimo) en que debería resultar + esta conversión. + </simpara> + </listitem> + <listitem> + <simpara> + Un <emphasis>especificador de precisión</emphasis> opcional que + indica cuántos dígitos decimales deben mostrarse para los números + en coma flotante. Esta opción no tienen efecto para otros tipos + que no sean double. (Otra función útil para formatear números + es <function>number_format</function>). + </simpara> + </listitem> + <listitem> + <para> + Un <emphasis>especificador de tipo</emphasis> que indica el tipo + a usar para tratar los datos de los argumentos. Los tipos posibles + son: + <simplelist> + <member> + <literal>%</literal> - un caracter literal de porcentaje. No se + precisa argumento. + </member> + <member> + <literal>b</literal> - el argumento es tratado como un entero y + presentado como un número binario. + </member> + <member> + <literal>c</literal> - el argumento es tratado como un entero, y + presentado como el caracter con dicho valor ASCII. + </member> + <member> + <literal>d</literal> - el argumento es tratado como un entero y + presentado como un número decimal. + </member> + <member> + <literal>f</literal> - el argumento es tratado como un doble y + presentado como un número de coma flotante. + </member> + <member> + <literal>o</literal> - el argumento es tratado como un entero, y + presentado como un número octal. + </member> + <member> + <literal>s</literal> - el argumento es tratado como una cadena y + es presentado como tal. + </member> + <member> + <literal>x</literal> - el argumento es tratado como un entero y + presentado como un número hexadecimal (con minúsculas). + </member> + <member> + <literal>X</literal> - el argumento es tratado como un entero y + presentado como un número hexadecimal (con mayúsculas). + </member> + </simplelist> + </para> + </listitem> + </orderedlist> + </para> + <simpara> + Vea también: <function>printf</function>, <function>sscanf</function>, + <function>fscanf</function>, y <function>number_format</function>. + </simpara> + </refsect1> + <refsect1> + <title>Ejemplos</title> + <para> + <example> + <title>Ejemplo de <function>Sprintf</function>: enteros rellenos con ceros</title> + <programlisting role="php"> +$fechaiso = sprintf ("%04d-%02d-%02d", $anno, $mes, $dia); + </programlisting> + </example> + <example> + <title>Ejemplo de <function>Sprintf</function>: formateando monedas</title> + <programlisting role="php"> +$pelas1 = 68.75; +$pelas2 = 54.35; +$pelas = $pelas1 + $pelas2; +// echo $pelas mostrará "123.1"; +$formateado = sprintf ("%01.2f", $pelas); +// echo $formateado mostrará "123.10" + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="function.strcasecmp"> + <refnamediv> + <refname>strcasecmp</refname> + <refpurpose> + Comparación de cadenas insensible a mayúsculas y minúsculas + y segura en modo binario + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcasecmp</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve &lt; 0 si <parameter>cad1</parameter> es menor que + <parameter>cad2</parameter>; &gt; 0 si <parameter>cad1</parameter> + es mayor que <parameter>cad2</parameter>, y 0 si son iguales. + <example> + <title>Ejemplo de <function>strcasecmp</function></title> + <programlisting role="php"> +$var1 = "Hello"; +$var2 = "hello"; +if (!strcasecmp ($var1, $var2)) { + echo '$var1 es igual a $var2 en una comparación sin tener en cuenta ' + .'mayúsculas o minúsculas'; +} + </programlisting> + </example> + </para> + <simpara> + Vea también <function>ereg</function>, <function>strcmp</function>, + <function>substr</function>, <function>stristr</function>, y + <function>strstr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strchr"> + <refnamediv> + <refname>strchr</refname> + <refpurpose> + Encuentra la primera aparición de un caracter + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strchr</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función es un alias para <function>strstr</function>, y es + idéntica en todo. + </para> + </refsect1> + </refentry> + + <refentry id="function.strcmp"> + <refnamediv> + <refname>strcmp</refname> + <refpurpose>Comparación de cadenas con seguridad binaria</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcmp</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Devuelve &lt; 0 si <parameter>cad1</parameter> es menor que + <parameter>cad2</parameter>; &gt; 0 si <parameter>cad1</parameter> + es mayor que <parameter>cad2</parameter>, y 0 si son iguales. + </simpara> + <simpara> + Nótese que esta comparación es sensible a mayúsculas y minúsculas. + </simpara> + <simpara> + Vea también <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strncmp</function>, + y <function>strstr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strcspn"> + <refnamediv> + <refname>strcspn</refname> + <refpurpose> + Encuentra la longitud del elemento inicial que no coincide + con la máscara + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcspn</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Devuelve la longitud del segmento inicial de + <parameter>cad1</parameter> que <emphasis>no</emphasis> + contiene ninguno de los caracteres de <parameter>cad2</parameter>. + </simpara> + <simpara> + Vea también <function>strspn</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strip-tags"> + <refnamediv> + <refname>strip_tags</refname> + <refpurpose>Elimina marcas HTML y PHP de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strip_tags</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string + <parameter><optional>etiq_permitidas</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función intenta eliminar todas las etiquetas HTML y PHP de + la cadena dada. Causa error por precaución en caso de etiquetas + incompletas o falsas. Utiliza la misma máquina de estados para + eliminar las etiquetas que la función <function>fgetss</function>. + </para> + <para> + Puede usar el parámetro opcional para especificar las etiquetas + que no deben eliminarse. + <note> + <para> + <parameter>etiq_permitidas</parameter> fue añadido en PHP 3.0.13, + PHP4B3. + </para> + </note> + </para> + </refsect1> + </refentry> + + <refentry id="function.stripcslashes"> + <refnamediv> + <refname>stripcslashes</refname> + <refpurpose> + Desmarca la cadena marcada con <function>addcslashes</function> + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>stripcslashes</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena con las barras invertidas eliminadas. + Reconoce las marcas tipo C <literal>\n</literal>, + <literal>\r</literal> ..., y la representación octal y + hexadecimal. + <note> + <simpara> + Añadida en PHP4b3-dev. + </simpara> + </note> + </para> + <simpara> + Vea también <function>addcslashes</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.stripslashes"> + <refnamediv> + <refname>stripslashes</refname> + <refpurpose> + Desmarca la cadena marcada con <function>addslashes</function> + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>stripslashes</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve una cadena con las barras invertidas eliminadas + (<literal>\'</literal> se convierte en <literal>'</literal>, + etc.). Las barras invertidas dobles se convierten en sencillas. + </para> + <simpara> + Vea también <function>addslashes</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.stristr"> + <refnamediv> + <refname>stristr</refname> + <refpurpose> + <function>strstr</function> sin tener en cuenta + mayúsculas o minúsculas + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>stristr</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve todo el <parameter>pajar</parameter> desde la primera + aparición de la <parameter>aguja</parameter>, siendo el + <parameter>pajar</parameter> examinado sin tener en cuenta + mayúsculas o minúsculas. + </para> + <para> + Si la <parameter>aguja</parameter> no se encuentra, devuelve + false. + </para> + <para> + Si la <parameter>aguja</parameter> no es una cadena, es convertida + a entero y usada como código de un carácter ASCII. + <para> + Vea también <function>strchr</function>, + <function>strrchr</function>, <function>substr</function>, y + <function>ereg</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strlen"> + <refnamediv> + <refname>strlen</refname> + <refpurpose>Obtiene la longitud de la cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strlen</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la longitud de la <parameter>cadena</parameter>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strnatcmp"> + <refnamediv> + <refname>strnatcmp</refname> + <refpurpose> + Compara cadenas usando un algoritmo de "orden natural" + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strnatcmp</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función implementa un algoritmo de comparación que ordena + las cadenas alfanuméricas como lo haría un ser humano, que es lo + que se denomina "orden natural". A continuación se puede ver un + ejemplo de la diferencia entre este algoritmo y los algoritmos de + ordenación de cadenas habituales en los ordenadores (utilizados + en <function>strcmp</function>): + <informalexample> + <programlisting> +$matriz1 = $matriz2 = array ("img12.png","img10.png","img2.png","img1.png"); +echo "Comparación de cadenas estándar\n"; +usort($matriz1,"strcmp"); +print_r($matriz1); +echo "\nComparación de cadenas en orden natural\n"; +usort($matriz2,"strnatcmp"); +print_r($matriz2); + </programlisting> + </informalexample> + El código anterior generará la siguiente salida: + <informalexample> + <programlisting> +Comparación de cadenas estándar +Array +( + [0] =&gt; img1.png + [1] =&gt; img10.png + [2] =&gt; img12.png + [3] =&gt; img2.png +) + +Comparación de cadenas en orden natural +Array +( + [0] =&gt; img1.png + [1] =&gt; img2.png + [2] =&gt; img10.png + [3] =&gt; img12.png +) + </programlisting> + </informalexample> + Para más información, vea la página de Martin Pool sobre + <ulink url="&url.strnatcmp;">Comparación de Cadenas en + Orden Natural</ulink>. + </para> + <simpara> + De forma similar a otras funciones de comparación de cadenas, + esta devuelve &lt; 0 si <parameter>cad1</parameter> es menor que + <parameter>cad2</parameter>; &gt; 0 si <parameter>cad1</parameter> + es mayor que <parameter>cad2</parameter>, y 0 si son iguales. + </simpara> + <simpara> + Nótese que esta comparación es sensible a mayúsculas y minúsculas. + </simpara> + <simpara> + Vea también <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + <function>strncmp</function>, <function>strnatcasecmp</function>, + y <function>strstr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strnatcasecmp"> + <refnamediv> + <refname>strnatcasecmp</refname> + <refpurpose> + Comparación de cadenas insensible a mayúsculas y minúsculas + usando un algoritmo de "orden natural" + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strnatcasecmp</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función implementa un algoritmo de comparación que ordena + las cadenas alfanuméricas como lo haría un ser humano. El + comportamiento de esta función es similar a + <function>strnatcmp</function>, pero la comparación no es + sensible a mayúsculas y minúsculas. Para más información, + vea la página de Martin Pool sobre + <ulink url="&url.strnatcmp;">Comparación de Cadenas en + Orden Natural</ulink>. + </para> + <simpara> + De forma similar a otras funciones de comparación de cadenas, + esta devuelve &lt; 0 si <parameter>cad1</parameter> es menor que + <parameter>cad2</parameter>; &gt; 0 si <parameter>cad1</parameter> + es mayor que <parameter>cad2</parameter>, y 0 si son iguales. + </simpara> + <simpara> + Vea también <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + <function>strncmp</function>, <function>strnatcmp</function>, + y <function>strstr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strncmp"> + <refnamediv> + <refname>strncmp</refname> + <refpurpose> + Comparación de los n primeros caracteres de cadenas, con + seguridad binaria + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strncmp</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + <paramdef>int <parameter>largo</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función es similar a <function>strcmp</function>, con la + diferencia que se puede especificar el (límite superior del) + número de caractares (<parameter>largo</parameter>) de cada + cadena que se usarán en la comparación. Si alguna de las cadenas + es menor que el <parameter>largo</parameter>, se usará su + longitud para la comparación. + </para> + <simpara> + + Devuelve &lt; 0 si <parameter>cad1</parameter> es menor que + <parameter>cad2</parameter>; &gt; 0 si <parameter>cad1</parameter> + es mayor que <parameter>cad2</parameter>, y 0 si son iguales. + </simpara> + <simpara> + Nótese que esta comparación es sensible a mayúsculas y minúsculas. + </simpara> + <simpara> + Vea también <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + y <function>strstr</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.str-pad"> + <refnamediv> + <refname>str_pad</refname> + <refpurpose>Rellena una cadena con otra hasta una longitud dada</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>str_pad</function></funcdef> + <paramdef>string <parameter>entrada</parameter></paramdef> + <paramdef>int <parameter>tama_relleno</parameter></paramdef> + <paramdef>string + <parameter><optional>cad_relleno</optional></parameter></paramdef> + <paramdef>int + <parameter><optional>tipo_relleno</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función rellena la cadena <parameter>entrada</parameter> por + la derecha, la izquierda o por ambos lados hasta el largo indicado. + Si no se especifica el argumento opcional + <parameter>cad_relleno</parameter>, <parameter>entrada</parameter> + es rellenada con espacios. En caso contrario, será rellenada con + los caracteres de <parameter>cad_relleno</parameter> hasta el límite. + </para> + + <para> + El argumento opcional <parameter>tipo_relleno</parameter> puede valer + STR_PAD_RIGHT, STR_PAD_LEFT, o STR_PAD_BOTH. Si no se especifica, se + asume que vale STR_PAD_RIGHT. + </para> + + <para> + Si el valor de <parameter>tama_relleno</parameter> es negativo o menor + que la longitud de la cadena de entrada, no se produce rellenado + alguno. + </para> + + <para> + <example> + <title>Ejemplo de <function>str_pad</function></title> + <programlisting role="php"> +$entrada = "Alien"; +print str_pad($entrada, 10); // produce "Alien " +print str_pad($entrada, 10, "-=", STR_PAD_LEFT); // produce "-=-=-Alien" +print str_pad($entrada, 10, "_", STR_PAD_BOTH); // produce "__Alien___" + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="function.strpos"> + <refnamediv> + <refname>strpos</refname> + <refpurpose> + Encuentra la posición de la primera aparición de una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strpos</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + <paramdef>int + <parameter><optional>desplazamiento</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la posición numérica de la primera aparición de la + <parameter>aguja</parameter> en la cadena + <parameter>pajar</parameter>. A diferencia de + <function>strrpos</function>, esta función puede tomar una + cadena completa como <parameter>aguja</parameter> y se utilizará + en su totalidad. + </para> + <para> + Si la <parameter>aguja</parameter> no es hayada, devuelve false. + <note> + <para> + Es fácil confundir los valores de retorno para "caracter encontrado + en la posición 0" y "caracter no encontrado". Aquí se indica cómo + detectar la diferencia: + <informalexample> + <programlisting role="php"> +// en PHP 4.0b3 y posteriores: +$pos = strpos ($micadena, "b"); +if ($pos === false) { // nota: tres signos igual + // no encontrado ... +} + +// en versiones anteriores a la 4.0b3: +$pos = strpos ($micadena, "b"); +if (is_string ($pos) &amp;&amp; !$pos) { + // no encontrado ... +} + </programlisting> + </informalexample> + </para> + </note> + </para> + <para> + Si la <parameter>aguja</parameter> no es una cadena, se convierte + a entero y se aplica como el valor ordinal de un caracter. + </para> + <para> + El parámetro opcional <parameter>desplazamiento</parameter> le permite + especificar a partir de qué caracter del <parameter>pajar</parameter> + comenzar a buscar. La posición devuelta es aún relativa al comienzo + de <parameter>pajar</parameter>. + </para> + <para> + Vea también <function>strrpos</function>, + <function>strrchr</function>, <function>substr</function>, + <function>stristr</function>, y <function>strstr</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strrchr"> + <refnamediv> + <refname>strrchr</refname> + <refpurpose> + Encuentra la última aparición de un caracter en una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strrchr</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función devuelve la porción del + <parameter>pajar</parameter> que comienza en la última aparición + de la <parameter>aguja</parameter> y continúa hasta el final + del <parameter>pajar</parameter>. + </para> + <para> + Devuelve false si la <parameter>aguja</parameter> no es hallada. + </para> + <para> + Si la <parameter>aguja</parameter> contiene más de un caracter, + sólo se usará el primero. + </para> + Si la <parameter>aguja</parameter> no es una cadena, se convierte + a entero y se aplica como el valor ordinal de un caracter. + <example> + <title>Ejemplo de <function>Strrchr</function></title> + <programlisting role="php"> +// obtener el último directorio de $PATH +$dir = substr (strrchr ($PATH, ":"), 1); + +// obtener todo tras el último salto de línea +$texto = "Line 1\nLine 2\nLine 3"; +$apell = substr (strrchr ($texto, 10), 1 ); + </programlisting> + </example> + </para> + <para> + Vea también <function>substr</function>, + <function>stristr</function>, y <function>strstr</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.str-repeat"> + <refnamediv> + <refname>str_repeat</refname> + <refpurpose>Repite una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>str_repeat</function></funcdef> + <paramdef>string <parameter>cad_entrada</parameter></paramdef> + <paramdef>int <parameter>veces</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la <parameter>cad_entrada</parameter> repetida + <parameter>veces</parameter>. + <parameter>veces</parameter> debe ser mayor que 0. + </para> + <example> + <title>Ejemplo de <function>Str_repeat</function></title> + <programlisting role="php"> +echo str_repeat ("-=", 10); + </programlisting> + </example> + <para> + Esto mostrará "-=-=-=-=-=-=-=-=-=-=". + </para> + <note> + <para> + Esta función fue añadida en el PHP 4.0. + </para> + </note> + </refsect1> + </refentry> + + <refentry id="function.strrev"> + <refnamediv> + <refname>strrev</refname> + <refpurpose>Invierte una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strrev</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuele la <parameter>cadena</parameter> invertida. + </para> + </refsect1> + </refentry> + + <refentry id="function.strrpos"> + <refnamediv> + <refname>strrpos</refname> + <refpurpose> + Encuentra la posición de la última aparición de un caracter en una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strrpos</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>char <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuele la posición numérica de la última aparición de + la <parameter>aguja</parameter> en el <parameter>pajar</parameter>. + Nótese que la aguja en este caso sólo puede ser un caracter único. + Si se pasa una cadena como aguja, sólo se utilizará el primer + caracter de la misma. + </para> + <para> + Si la <parameter>aguja</parameter> no es hayada, devuelve false. + </para> + <para> + Si la <parameter>aguja</parameter> no es una cadena, se convierte + a entero y se aplica como el valor ordinal de un caracter. + </para> + <para> + Vea también <function>strpos</function>, + <function>strrchr</function>, <function>substr</function>, + <function>stristr</function>, y <function>strstr</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strspn"> + <refnamediv> + <refname>strspn</refname> + <refpurpose> + Encuentra la longitud del segmento inicial que coincide con la + máscara + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strspn</function></funcdef> + <paramdef>string <parameter>cad1</parameter></paramdef> + <paramdef>string <parameter>cad2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + Devuelve la longitud del segmento inicial de + <parameter>cad1</parameter> que consiste por entero en + caracteres contenidos en <parameter>cad2</parameter>. + </simpara> + <para> + <informalexample> + <programlisting role="php"> +strspn ("42 es la respuesta. ¿Cuál es la pregunta ...?", "1234567890"); + </programlisting> + <para> + devolverá 2 como resultado. + </para> + </informalexample> + </para> + <simpara> + Vea también <function>strcspn</function>. + </simpara> + </refsect1> + </refentry> + + <refentry id="function.strstr"> + <refnamediv> + <refname>strstr</refname> + <refpurpose>Encuentra la primera aparición de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strstr</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve todo el <parameter>pajar</parameter> desde la primera + aparición de la <parameter>aguja</parameter> hasta el final. + </para> + <para> + Si la <parameter>aguja</parameter> no es hayada, devuelve false. + </para> + <para> + Si la <parameter>aguja</parameter> no es una cadena, se convierte + a entero y se aplica como el valor ordinal de un caracter. + </para> + <para> + <note> + <para> + Nótese que esta función es sensible a mayúsculas y minúsculas. + Para búsquedas no sensibles, utilice <function>stristr</function>. + </para> + </note> + </para> + <para> + <example> + <title>Ejemplo de <function>Strstr</function></title> + <programlisting role="php"> +$email = 'sterling@designmultimedia.com'; +$dominio = strstr ($email, '@'); +print $dominio; // imprime @designmultimedia.com + </programlisting> + </example> + </para> + <para> + Vea también <function>stristr</function>, + <function>strrchr</function>, <function>substr</function>, y + <function>ereg</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strtok"> + <refnamediv> + <refname>strtok</refname> + <refpurpose>Divide una cadena en elementos</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtok</function></funcdef> + <paramdef>string <parameter>arg1</parameter></paramdef> + <paramdef>string <parameter>arg2</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>strtok</function> se usa para dividir en elementos una + cadena. Es decir, que si tiene una cadena como "Esta es una cadena + de ejemplo" podría dividirla en palabras individuales utilizando + el espacio como divisor. + <example> + <title>Ejemplo de <function>Strtok</function></title> + <programlisting role="php"> +$cadena = "Esta es una cadena de ejemplo"; +$tok = strtok ($cadena," "); +while ($tok) { + echo "Palabra=$tok&lt;br>"; + $tok = strtok (" "); +} + </programlisting> + </example> + </para> + <para> + Nótese que sólo la primera llamada a strtok utiliza el argumento + cadena. Cada llamada subsiguiente necesita sólo el divisor a + utilizar, puesto que ella guarda la posición actual en la cadena. + Para comenzar de nuevo o para dividir otra cadena, simplemente + llame a strtok con el argumento de cadena y se inicializará. + Nótese que puede poner divisores múltiples como parámetro. La + cadena será dividida cuando alguno de los caracteres del argumento + sea hallado. + </para> + <para> + Además tenga cuidado si sus divisores valen "0", pues evalúa + como false en las expresiones condicionales. + </para> + <para> + Vea también <function>split</function> y + <function>explode</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strtolower"> + <refnamediv> + <refname>strtolower</refname> + <refpurpose>Pasa a minúsculas una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtolower</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la <parameter>cadena</parameter> con todas sus letras + en minúsculas. + </para> + <para> + Nótese que las letras son definidad por el locale actual. Esto + quiere decir que, por ejemplo, en el locale por defecto ("C"), + los caracteres como la Ñ no serán convertidos. + </para> + <example> + <title>Ejemplo de <function>Strtolower</function></title> + <programlisting role="php"> +$cad = "María Tenía Un Corderito al que QUERÍA Mucho"; +$cad = strtolower($cad); +print $cad; # Visualiza maría tenía un corderito al que querÍa mucho + </programlisting> + </example> + <para> + Vea también <function>strtoupper</function> + y <function>ucfirst</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strtoupper"> + <refnamediv> + <refname>strtoupper</refname> + <refpurpose>Pasa a mayúsculas una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtoupper</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Devuelve la <parameter>cadena</parameter> con todas sus letras + en mayúsculas. + </para> + <para> + Nótese que las letras son definidad por el locale actual. Esto + quiere decir que, por ejemplo, en el locale por defecto ("C"), + los caracteres como la ñ no serán convertidos. + </para> + <example> + <title>Ejemplo de <function>Strtoupper</function></title> + <programlisting role="php"> +$cad = "María Tenía Un Corderito al que QUERÍA Mucho"; +$cad = strtoupper ($cad); +print $cad; # Visuaiza MARíA TENíA UN CORDERITO AL QUE QUERÍA MUCHO + </programlisting> + </example> + <para> + Vea también <function>strtolower</function> + and <function>ucfirst</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.str-replace"> + <refnamediv> + <refname>str_replace</refname> + <refpurpose> + Sustitiye todas las apariciones de la aguja en el pajar por la cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>str_replace</function></funcdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función sustituye todas las apariciones de la + <parameter>aguja</parameter> en el <parameter>pajar</parameter> + por la <parameter>cad</parameter> dada. Si no precisa reglas + especiales de sustitución, deberá usar siempre esta función en + lugar de <function>ereg_replace</function>.</para> + <para> + <example> + <title>Ejemplo de <function>Str_replace</function></title> + <programlisting role="php"> +$bodytag = str_replace ("%cuerpo%", "negro", "&lt;body text=%cuerpo%>"); + </programlisting> + </example> + </para> + <para> + Esta función tiene seguridad binaria. + </para> + <note> + <para> + <function>Str_replace</function> fue añadida en PHP 3.0.6, pero tuvo + errores hasta el PHP 3.0.8. + </para> + </note> + <para> + Vea también <function>ereg_replace</function> y + <function>strtr</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.strtr"> + <refnamediv> + <refname>strtr</refname> + <refpurpose>Traduce ciertos caracteres</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtr</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>string <parameter>desde</parameter></paramdef> + <paramdef>string <parameter>hasta</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función trabaja sobre <parameter>cad</parameter>, traduciendo + todas las apariciones de cada caracter en <parameter>desde</parameter> + por el caracter correspondiente en <parameter>hasta</parameter> y + devolviendo el resultado. + </para> + <para> + Si <parameter>desde</parameter> y <parameter>hasta</parameter> son + de distinta longitud, los caracteres extra en la más larga son + ignorados. + <example> + <title>Ejemplo de <function>Strtr</function></title> + <programlisting role="php"> +$addr = strtr($addr, "äåö", "aao"); + </programlisting> + </example> + </para> + <para> + <function>strtr</function> puede llamarso sólo con dos argumentos. + Si se llama de esta manera, se comporta de otro modo: + <parameter>desde</parameter> debe ser entonces una matriz que + contenga pares cadena -> cadena que serán sustituídos en la + cadena fuente. <function>strtr</function> siempre buscará la + coincidencia más larga primero y *NO* intentará sustituir nada + en lo que haya trabajado ya. + </para> + <para> + Ejemplos: + <informalexample> + <programlisting role="php"> +$trad = array ("hola" =&gt; "hey", "hey" =&gt; "hola"); +echo strtr("hey a todos, dije hola", $trad) . "\n"; + </programlisting> + </informalexample> + Mostrará: "hola a todos, dije hey", + </para> + <note> + <simpara> + Esta característica (2 argumentos) fue añadida en el PHP 4.0 + </simpara> + </note> + <para> + Vea también <function>ereg_replace</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.substr"> + <refnamediv> + <refname>substr</refname> + <refpurpose>Devuelve parte de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>substr</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + <paramdef>int <parameter>comienzo</parameter></paramdef> + <paramdef>int + <parameter><optional>largo</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + substr devuelve la porción de <parameter>cadena</parameter> + especificada por los parámetros <parameter>comienzo</parameter> + y <parameter>largo</parameter>. + </para> + <para> + Si <parameter>comienzo</parameter> es positivo, la cadena devuelta + comenzará en dicho caracter de <parameter>cadena</parameter>. + </para> + <para> + Ejemplos: + <informalexample> + <programlisting role="php"> +$resto = substr ("abcdef", 1); // devuelve "bcdef" +$resto = substr ("abcdef", 1, 3); // devuelve "bcd" + </programlisting> + </informalexample> + </para> + <para> + Si <parameter>comienzo</parameter> es negativo, la cadena devuelta + comenzará en dicha posición desde el final de + <parameter>cadena</parameter>. + </para> + <para> + Ejemplos: + <informalexample> + <programlisting role="php"> +$resto = substr ("abcdef", -1); // devuelve "f" +$resto = substr ("abcdef", -2); // devuelve "ef" +$resto = substr ("abcdef", -3, 1); // devuelve "d" + </programlisting> + </informalexample> + </para> + <para> + Si se especifica <parameter>largo</parameter> y es positivo, la + cadena devuelta terminará <parameter>largo</parameter> caracteres + tras el <parameter>comienzo</parameter>. Si esto resulta en una + cadena con longitud negativa (porque el comienzo está pasado el + final de la cadena), la cadena devuelta contendrá únicamente el + caracter que haya en <parameter>comienzo</parameter>. + </para> + <para> + Si se especifica <parameter>largo</parameter> y es negativo, la + cadena devuelta terminará a <parameter>largo</parameter> caracteres + desde el final de <parameter>cadena</parameter>. Si esto resulta en una + cadena con longitud negativa, la cadena devuelta contendrá + únicamente el caracter que haya en <parameter>comienzo</parameter>. + </para> + <para> + Examples: + <informalexample> + <programlisting role="php"> +$resto = substr ("abcdef", 1, -1); // devuelve "bcde" + </programlisting> + </informalexample> + </para> + <para> + Vea también <function>strrchr</function> y + <function>ereg</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.substr-count"> + <refnamediv> + <refname>substr_count</refname> + <refpurpose>Cuenta el número de apariciones de la subcadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>substr_count</function></funcdef> + <paramdef>string <parameter>pajar</parameter></paramdef> + <paramdef>string <parameter>aguja</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>substr_count</function> devuelve el número de veces + que la subcadena <parameter>aguja</parameter> se encuentra en + la cadena <parameter>pajar</parameter>. + </para> + + <para> + <example> + <title>Ejemplo de <function>substr_count</function></title> + <programlisting> +print substr_count("This is a test", "is"); // prints out 2 + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="function.substr-replace"> + <refnamediv> + <refname>substr_replace</refname> + <refpurpose>Sustituye texto en una parte de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>substr_replace</function></funcdef> + <paramdef>string <parameter>cadena</parameter></paramdef> + <paramdef>string <parameter>sustituto</parameter></paramdef> + <paramdef>int <parameter>comienzo</parameter></paramdef> + <paramdef>int + <parameter><optional>largo</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>substr_replace</function> sustituye la parte de + <parameter>cadena</parameter> delimitada por los parámetros + <parameter>comienzo</parameter> y (opcionalmente) + <parameter>largo</parameter> por la cadena dada en + <parameter>sustituto</parameter>. Se devuelve el resultado. + </para> + <para> + Si <parameter>comienzo</parameter> es positivo, la sustitución + comenzará en dicha posición dentro de la <parameter>cadena</parameter>. + </para> + <para> + Si <parameter>comienzo</parameter> es negativo, la sustitución + comenzará en dicha posición pero contando desde el final de + <parameter>cadena</parameter>. + </para> + <para> + Si se especifica el <parameter>largo</parameter> y es positivo, + representa el largo de la porción de + <parameter>cadena</parameter> a sustituir. Si es negativo, + representa el número de caracteres desde el final de + <parameter>cadena</parameter> en los que dejar de sustituir. + Si no se especifica, valdrá por defecto + strlen(<parameter>cadena</parameter>); es decir, que acabará + la sustitución al final de <parameter>cadena</parameter>. + </para> + <para> + <example> + <title>Ejemplo de <function>Substr_replace</function></title> + <programlisting role="php"> +&lt;?php +$var = 'ABCDEFGH:/MNRPQR/'; +echo "Original: $var&lt;hr&gt;\n"; + +/* Estos dos ejemplos sustituyen toda $var por 'bob'. */ +echo substr_replace ($var, 'bob', 0) . "&lt;br&gt;\n"; +echo substr_replace ($var, 'bob', 0, strlen ($var)) . "&lt;br&gt;\n"; + +/* Inserta 'bob' justo al inicio de $var. */ +echo substr_replace ($var, 'bob', 0, 0) . "&lt;br&gt;\n"; + +/* Los dos siguientes cambian 'MNRPQR' en $var por 'bob'. */ +echo substr_replace ($var, 'bob', 10, -1) . "&lt;br&gt;\n"; +echo substr_replace ($var, 'bob', -7, -1) . "&lt;br&gt;\n"; + +/* Borrar 'MNRPQR' de $var. */ +echo substr_replace ($var, '', 10, -1) . "&lt;br&gt;\n"; +?&gt; + </programlisting> + </example> + </para> + <para> + Vea también <function>str_replace</function> y + <function>substr</function>. + </para> + <note> + <simpara> + <function>Substr_replace</function> fue añadida en el PHP 4.0. + </simpara> + </note> + </refsect1> + </refentry> + + <refentry id="function.trim"> + <refnamediv> + <refname>trim</refname> + <refpurpose> + Elimina espacios del principio y final de una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>trim</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Esta función elimina los espacios en blanco del comienzo y del + final de una cadena y devuelve el resultado. Los caracteres de + espacio que elimina realmente son: "\n", "\r", "\t", "\v", "\0", + y el espacio en sí. + </para> + <para> + Vea también <function>chop</function> y + <function>ltrim</function>. + </para> + </refsect1> + </refentry> + + <refentry id="function.ucfirst"> + <refnamediv> + <refname>ucfirst</refname> + <refpurpose>Pasar a mayúsculas el primer caracter de una cadena</refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ucfirst</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Pone en mayúsculas el primer carácter de <parameter>cad</parameter> + si es alfabético. + </para> + <para> + Nótese que 'alfabético' está determinado por la localidad actual. + Por ejemplo, en la localidad por defecto "C", los caracteres como + la a con diéresis (ä) no serán convertidos. + <example> + <title>Ejemplo de <function>Ucfirst</function></title> + <programlisting role="php"> +$texto = 'susanita tiene un ratón, un ratón chiquitín.'; +$texto = ucfirst ($texto); // $texto vale ahora: Susanita tiene un + // ratón, un ratón chiquitín. + </programlisting> + </example> + </para> + <para> + Vea también <function>strtoupper</function> y + <function>strtolower</function> + </para> + </refsect1> + </refentry> + + <refentry id="function.ucwords"> + <refnamediv> + <refname>ucwords</refname> + <refpurpose> + Pone en mayúsculas el primer caracter de cada palabra + de una cadena + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ucwords</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + Pasa a mayúsculas la primera letra de cada palabra en + <parameter>cad</parameter> si dicho caracter es alfabético. + <example> + <title>Ejemplo de <function>ucwords</function></title> + <programlisting role="php"> +$texto = "susanita tiene un ratón, un ratón chiquitín."; +$texto = ucwords($texto); // $texto vale ahora: Susanita Tiene Un + // Ratón, Un Ratón Chiquitín. + </programlisting> + </example> + </para> + <para> + Vea también <function>strtoupper</function>, + <function>strtolower</function> y <function>ucfirst</function>. + </para> + </refsect1> + </refentry> + + + <refentry id="function.wordwrap"> + <refnamediv> + <refname>wordwrap</refname> + <refpurpose> + Corta una cadena en un número dado de caracteres usando un + caracter de ruptura de cadenas. + </refpurpose> + </refnamediv> + <refsect1> + <title>Descripción</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>wordwrap</function></funcdef> + <paramdef>string <parameter>cad</parameter></paramdef> + <paramdef>int + <parameter><optional>ancho</optional></parameter> + </paramdef> + <paramdef>string + <parameter><optional>ruptura</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + Corta la cadena <parameter>cad</parameter> en la columna + especificada por el parámetro (opcional) <parameter>ancho</parameter>. + La línea se rompe utilizando el parámetro (opcional) + <parameter>ruptura</parameter>. + </para> + <para> + <function>wordwrap</function> automáticamente cortará en la + columna 75 y usará '\n' (nueva línea) si no se especifican + el <parameter>ancho</parameter> o la <parameter>ruptura</parameter>. + </para> + <para> + <example> + <title>Ejemplo de <function>wordwrap</function></title> + <programlisting role="php"> +$texto = "El veloz murciélago hindú comía feliz cardillo y kiwi."; +$textonuevo = wordwrap( $texto, 20 ); + +echo "$textonuevo\n"; + </programlisting> + </example> + </para> + <para> + Este ejemplo mostraría: + </para> + <para> + <informalexample> + <programlisting> +El veloz murciélago +hindú comía feliz cardillo y kiwi. + </programlisting> + </informalexample> + </para> + <para> + Vea también <function>nl2br</function>. + </para> + </refsect1> + </refentry> + + + </reference> + +<!-- 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 +sgml-parent-document:nil +sgml-default-dtd-file:"../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +--> \ No newline at end of file
« previous php.doc (#969333114) next »