cycle98 Mon Jan 29 20:17:21 2001 EDT Modified files: /phpdoc/kr/functions strings.xml Log: 1st translation english to korean by SeungHwan Lee
Index: phpdoc/kr/functions/strings.xml diff -u phpdoc/kr/functions/strings.xml:1.2 phpdoc/kr/functions/strings.xml:1.3 --- phpdoc/kr/functions/strings.xml:1.2 Fri Jan 12 06:16:40 2001 +++ phpdoc/kr/functions/strings.xml Mon Jan 29 20:17:20 2001 @@ -1,3253 +1,3254 @@ - <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> - - <para> - For information on how strings behave, especially with regard to - usage of single quotes, double quotes, and escape sequences, see - the <link linkend="language.types.string">Strings</link> entry in - the <link linkend="language.types">Types</link> section of the - manual. - </para> - </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> - <note> - <para> - <function>chop</function> is different than the Perl - <parameter>chop()</parameter> function, which removes the last - character in the string. - </para> - </note> - <para> - See also <function>trim</function>, <function>ltrim</function>, - <function>rtrim</function>, and <function>chop</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, one 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> - If you are using the supplied salt, you should be aware that the - salt is generated once. If you are calling this function - recursively, this may impact both appearance and, to a certain - extent, security. - </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> - <note> - <para> - The <parameter>limit</parameter> parameter was added in PHP 4.0.1 - </para> - </note> - <para> - <example> - <title><function>Explode</function> example</title> - <programlisting role="php"> -$pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; -$pieces = explode (" ", $pizza); - </programlisting> - </example> - </para> - <note> - <para> - Although <function>implode</function> can for historical reasons - accept its parameters in either order, - <function>explode</function> cannot. You must ensure that the - <parameter>separator</parameter> argument comes before the - <parameter>string</parameter> argument. - </para> - </note> - <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> - <paramdef>int <parameter><optional>quote_style</optional></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>. There are two new defines - (<parameter>HTML_ENTITIES</parameter>, - <parameter>HTML_SPECIALCHARS</parameter>) that allow you to - specify the table you want. And as in the - <function>htmlspecialchars</function> and - <function>htmlentities</function> functions you can optionally specify the - quote_style you are working with. The default is ENT_COMPAT mode. See - the description of these modes in <function>htmlspecialchars</function>. - <example> - <title>Translation Table Example</title> - <programlisting role="php"> -$trans = get_html_translation_table (HTML_ENTITIES); -$str = "Hallo & <Frau> & Krämer"; -$encoded = strtr ($str, $trans); - </programlisting> - </example> - The <literal>$encoded</literal> variable will now contain: "Hallo - &<sgmltag>amp</sgmltag>; - &<sgmltag>lt</sgmltag>;Frau&<sgmltag>gt</sgmltag>; - &<sgmltag>amp</sgmltag>; Kr&<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 & - <Frau> & Krä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 <meta> tags of the form - <example> - <title>Meta Tags Example</title> - <programlisting role="html"> -<meta name="author" content="name"> -<meta name="tags" content="php3 documentation"> -</head> <!-- 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 "<br>\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> - <paramdef>int <parameter><optional>quote_style</optional></parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function is identical to - <function>htmlspecialchars</function> in all ways, except that - all characters which have HTML character entity equivalents are - translated into these entities. Like - <function>htmlspecialchars</function>, it takes an optional - second argument which indicates what should be done with single - and double quotes. <constant>ENT_COMPAT</constant> (the default) - will only convert double-quotes and leave single-quotes alone. - <constant>ENT_QUOTES</constant> will convert both double and - single quotes, and <constant>ENT_NOQUOTES</constant> will leave - both double and single quotes unconverted. - </para> - <para> - At present, the ISO-8859-1 character set is used. Note that the optional - second argument was added in PHP 3.0.17 and PHP 4.0.3. - </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> - <paramdef>int <parameter><optional>quote_style</optional></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 some of these - conversions made; the translations made are those most - useful for everyday web programming. If you require all HTML - character entities to be translated, use - <function>htmlentities</function> instead. - </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. The optional second argument, quote_style, tells the - function what to do with single and double quote characters. The - default mode, ENT_COMPAT, is the backwards compatible mode which only - translates the double-quote character and leaves the single-quote - untranslated. If ENT_QUOTES is set, both single and double quotes - are translated and if ENT_NOQUOTES is set neither single nor double quotes - are translated. - </simpara> - <para> - The translations performed are: - <itemizedlist> - <listitem> - <simpara> - '&' (ampersand) becomes '&amp;' - </simpara> - </listitem> - <listitem> - <simpara> - '"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set. - </simpara> - </listitem> - <listitem> - <simpara> - ''' (single quote) becomes '&#039;' only when ENT_QUOTES is set. - </simpara> - </listitem> - <listitem> - <simpara> - '<' (less than) becomes '&lt;' - </simpara> - </listitem> - <listitem> - <simpara> - '>' (greater than) becomes '&gt;' - </simpara> - </listitem> - </itemizedlist> - <example> - <title><function>htmlspecialchars</function> example</title> - <programlisting role="php"> -$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); - </programlisting> - </example> - </para> - <para> - Note that this function does not translate anything beyond what - is listed above. For full entity translation, see - <function>htmlentities</function>. Also note that the optional second - argument was added in PHP 3.0.17 and PHP 4.0.3. - </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> - <note> - <para> - <function>implode</function> can, for historical reasons, accept - its parameters in either order. For consistency with - <function>explode</function>, however, it may be less confusing - to use the documented order of arguments. - </para> - </note> - <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> - <funcprototype> - <funcdef>int <function>levenshtein</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - <paramdef>int <parameter>cost_ins</parameter></paramdef> - <paramdef>int <parameter>cost_rep</parameter></paramdef> - <paramdef>int <parameter>cost_del</parameter></paramdef> - </funcprototype> - <funcprototype> - <funcdef>int <function>levenshtein</function></funcdef> - <paramdef>string <parameter>str1</parameter></paramdef> - <paramdef>string <parameter>str2</parameter></paramdef> - <paramdef>function <parameter>cost</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <para> - This function returns the Levenshtein-Distance between the - two argument strings or -1, if one of the argument strings - is longer than the limit of 255 characters (255 should be - more than enough for name or dictionary comparison, and - nobody serious would be doing genetic analysis with PHP). - </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> - In its simpelest form the function will take only the two - strings as parameter and will calculate just the number of - insert, replace and delete operations needed to transform - <parameter>str1</parameter> into <parameter>str2</parameter>. - </para> - <para> - A second variant will take three additional parameters that - define the cost of insert, replace and delete operations. - This is more general and adaptive than variant one, but not - as efficient. - </para> - <para> - The third variant (which is not implemented yet) will be - the most general and adaptive, but also the slowest alternative. - It will call a user-supplied function that will determine the - cost for every possible operation. - </para> - <para> - The user-supplied function will be called with the following - arguments: - <itemizedlist> - <listitem> - <simpara> - operation to apply: 'I', 'R' or 'D' - </simpara> - </listitem> - <listitem> - <simpara> - actual character in string 1 - </simpara> - </listitem> - <listitem> - <simpara> - actual character in string 2 - </simpara> - </listitem> - <listitem> - <simpara> - position in string 1 - </simpara> - </listitem> - <listitem> - <simpara> - position in string 2 - </simpara> - </listitem> - <listitem> - <simpara> - remaining characters in string 1 - </simpara> - </listitem> - <listitem> - <simpara> - remaining characters in string 2 - </simpara> - </listitem> - </itemizedlist> - The user-supplied function has to return a positive integer - describing the cost for this particular operation, but it - may decide to use only some of the supplied arguments. - </para> - <para> - The user-supplied function approach offers the possibility to - take into account the relevance of and/or difference between - certain symbols (characters) or even the context those symbols - appear in to determine the cost of insert, replace and delete - operations, but at the cost of loosing all optimizations done - regarding cpu register utilization and cache misses that have - been worked into the other two variants. - </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>, <function>rtrim</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 - <[EMAIL PROTECTED]>. It is described in ["Practical - Algorithms for Programmers", Binstock & 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 '<BR>' 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> - <paramdef>array <parameter><optional>arr</optional></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. If - the second parameter <parameter>arr</parameter> is present, - variables are stored in this variable as an array elements instead. - </para> - <para> - <example> - <title>Using <function>parse_str</function></title> - <programlisting role="php"> -$str = "first=value&second[]=this+works&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>, and - <function>rtrim</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", &$id, &$first, &$last); -echo "<author id='$id'> - <firstname>$first</firstname> - <surname>$last</surname> -</author>\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 ("Hilbert") == soundex ("Heilbronn") == 'H416'; -soundex ("Knuth") == soundex ("Kant") == 'K530'; -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 of 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 a percent sign - (<literal>%</literal>), followed by one or more 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.strncasecmp"> - <refnamediv> - <refname>strncasecmp</refname> - <refpurpose> - Binary safe case-insensitive string comparison of the first n characters - </refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <funcsynopsis> - <funcprototype> - <funcdef>int <function>strncasecmp</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>strcasecmp</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 < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>strcmp</function>, <function>substr</function>, - <function>stristr</function>, and <function>strstr</function>. - </simpara> - </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 < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>, - <function>strncasecmp</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 < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>strncasecmp</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] => img1.png - [1] => img10.png - [2] => img12.png - [3] => img2.png -) - -Natural order string comparison -Array -( - [0] => img1.png - [1] => img2.png - [2] => img10.png - [3] => 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 - < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>strncasecmp</function>, - <function>strnatcasecmp</function>, <function>strstr</function>, - <function>natsort</function> and <function>natcasesort</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 - < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>strncasecmp</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 < 0 if <parameter>str1</parameter> is less than - <parameter>str2</parameter>; > 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>strncasecmp</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) && !$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. - <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 = strrpos ($mystring, "b"); -if ($pos === false) { // note: three equal signs - // not found... -} - -// in versions older than 4.0b3: -$pos = strrpos ($mystring, "b"); -if (is_string ($pos) && !$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> - 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 = '[EMAIL PROTECTED]'; -$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<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", "<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" => "hi", "hi" => "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 position in - <parameter>string</parameter>, counting from zero. For instance, - in the string '<literal>abcdef</literal>', the character at - position <literal>0</literal> is '<literal>a</literal>', the - character at position <literal>2</literal> is - '<literal>c</literal>', and so forth. - </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"> -<?php -$var = 'ABCDEFGH:/MNRPQR/'; -echo "Original: $var<hr>\n"; - -/* These two examples replace all of $var with 'bob'. */ -echo substr_replace ($var, 'bob', 0) . "<br>\n"; -echo substr_replace ($var, 'bob', 0, strlen ($var)) . "<br>\n"; - -/* Insert 'bob' right at the beginning of $var. */ -echo substr_replace ($var, 'bob', 0, 0) . "<br>\n"; - -/* These next two replace 'MNRPQR' in $var with 'bob'. */ -echo substr_replace ($var, 'bob', 10, -1) . "<br>\n"; -echo substr_replace ($var, 'bob', -7, -1) . "<br>\n"; - -/* Delete 'MNRPQR' from $var. */ -echo substr_replace ($var, '', 10, -1) . "<br>\n"; -?> - </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>, <function>rtrim</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> - <note> - <simpara> - The definition of a word is any string of characters - that is immediately after a whitespace (These are: - space, form-feed, newline, carriage return, horizontal tab, - and vertical tab). - </simpara> - </note> - </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> - <paramdef>int - <parameter><optional>cut</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> - If the <parameter>cut</parameter> is set to 1, the string is - always wrapped at the specified width. So if you have a word - that is larger than the given width, it is broken appart. - (See second example). - <note> - <para> - The <parameter>cut</parameter> parameter was added in PHP 4.0.3. - </para> - </note> - </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> - <example> - <title><function>wordwrap</function> example</title> - <programlisting role="php"> -$text = "A very long woooooooooooord."; -$newtext = wordwrap( $text, 8, "\n", 1); - -echo "$newtext\n"; - </programlisting> - </example> - </para> - <para> - This example would display: - </para> - <para> - <informalexample> - <programlisting> -A very -long -wooooooo -ooooord. - </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>String functions</title> + <titleabbrev>Strings</titleabbrev> + <partintro> + <simpara> + 이들 함수는 모두 다양한 방법으로 문자열을 다룬다. +정규 표현 섹션과 URL 핸들링 섹션에서좀 더 다양하고 특별한 +함수들을 만나 볼 수 있다. + </simpara> + <para> + 어떻게 문자열이 적용되고, 특히 작은 따옴표와 +큰따옴표 그리고 에스케이프 시퀀스(escape sequence)와 어떤 관계가 +있는지는 이 메뉴얼의 + <link linkend="language.types">Types</link>섹션의 <link +linkend="language.types.string">Strings</link>편을 참조하기 바란다. + </para> + </partintro> + <refentry id="function.addcslashes"> + <refnamediv> + <refname>AddCSlashes</refname> + <refpurpose>C형태로 문자를 인용한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string +<function>addcslashes</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + <paramdef>string +<parameter>charlist</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>charlist</parameter>파라미터에 +나오는 문자 앞에 백슬래쉬를 위치시킨 문자열을 반환한다. + 이 함수는 C 스타일의 <literal>\n</literal>, +<literal>\r</literal>등을 이스케이프 하고, 32 보다 작거나 126 보다 +큰 ASCII 코드는 팔진수 표현으로 변환된다. + 알파벳과 숫자를 에스케이프할 때 주의하라. + "\0..\37"과 같이 특별한 범위를 +<parameter>charlist</parameter>에서 지정할 수 있으며, 이는 ASCII 코드 +0과 31 사이의 모든 문자를 이스케이프 할 것이다. + <example> + <title> + <function>Addcslashes</function>의 +예</title> + <programlisting role="php"> +$escaped = addcslashes ($not_escaped, "\0..\37!@\177..\377"); + </programlisting> + </example> + <note> + <simpara> + PHP4b3-dev 에서 추가되었다.</simpara> + </note> + </para> + <para> + <function>stripcslashes</function>, + <function>stripslashes</function>, + <function>htmlspecialchars</function>, + <function>htmlspecialchars</function>, 그리고 + <function>quotemeta</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.addslashes"> + <refnamediv> + <refname>AddSlashes</refname> + <refpurpose>슬래쉬로 문자를 인용한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>addslashes</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 데이터 베이스 쿼리와 같이 인용된 부분 앞에 +백슬래쉬를 붙여 반환한다. + 이런 문자에는 작은따옴표 (<literal>'</literal>), +큰따옴표(<literal>"</literal>),백슬래쉬(<literal>\</literal>), 그리고 +NULL(null byte)이 있다. + </para> + <para> + <function>stripslashes</function>, + <function>htmlspecialchars</function>, 그리고 + <function>quotemeta</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.bin2hex"> + <refnamediv> + <refname>bin2hex</refname> + <refpurpose> + 십진 데이터를 16진수 표현으로 변환한다. </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>bin2hex</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str</parameter>의 16진수 표현은 +갖는 ASCII 스트링으로 반환한다. 변환은 하이-니블(high-nibble)을 +시작으로 하는 바이트 와이즈(byte0wise) 방식으로 진행된다. + </para> + </refsect1> + </refentry> + <refentry id="function.chop"> + <refnamediv> + <refname>Chop</refname> + <refpurpose>뒤부분의 공백을 제거한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>chop</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 뉴라인(newline)을 포함하는 뒷부분의 공백을 +제거한 문자열을 반환한다. + <example> + <title> + <function>Chop</function>의 +예</title> + <programlisting role="php"> +$trimmed = chop ($line); + </programlisting> + </example> + </para> + <note> + <para> + <function>chop</function> 은 마지막 +문자를 제거하는 펄(Perl)에 있어서의 <parameter>chop()</parameter> +함수와 다르다. + </para> + </note> + <para> + <function>trim</function>, <function>ltrim</function>, + <function>rtrim</function>, 그리고 <function>chop</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.chr"> + <refnamediv> + <refname>Chr</refname> + <refpurpose>특정 문자를 반환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>chr</function> + </funcdef> + <paramdef>int <parameter>ascii</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>ascii</parameter>에 의해 정의된 +문자를 나타내는 문자를 반환한다. + <example> + <title> + <function>Chr</function> 의 +예</title> + <programlisting role="php"> +$str .= chr (27); /* $str 의 끝에 에스케이프 문자를 추가한다. */ + +/* 때로 다음과 같은 예가 더욱 유용하다. */ + +$str = sprintf ("The string ends in escape: %c", 27); + </programlisting> + </example> + 이 함수는 <function>ord</function> 함수와 대응된다. + <literal>%c</literal> 포멧을 사용한 <function>sprintf</function>함수를 +참고하라. + </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> + 키릴 문자(Cyrillic character) 셋을 다른것으로 변환한다. +</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 주어진 키릴 문자 셋 하나를 다른것으로 변환한다. + <parameter>from</parameter>과 <parameter>to</parameter> 인수는 소스와 +타겟 키릴 문자셋을 나타내는 하나의 문자이다. + 지원되는 타입은 다음과 같다: + <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> + 문자열에 사용된 글자에 관한 정보를 반환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <parameter>string</parameter>에 있는 0..255 +바이트에 대한 빈도 수를 세고, 그것을 다양한 방법으로 +반환한다. + 선택적인 매개변수 <parameter>Mode</parameter> 는 0 으로 그 +기본값이 정해진다. + <parameter>mode</parameter>의 값에 따라 <function>count_chars</function> +은 다음중의 하나를 반환한다: + <itemizedlist> + <listitem> + <simpara> + 0 - 바이트-값(0..255)을 키로 하고 매 바이트의 빈도를 +값으로 하는 배열. + </simpara> + </listitem> + <listitem> + <simpara> + 1 - 0 과 같으나 바이트-값의 빈도가 0보타 큰 것들만. + </simpara> + </listitem> + <listitem> + <simpara> + 2 - 0 과 같으나 바이트-값 이 0 인 것들만. + </simpara> + </listitem> + <listitem> + <simpara> + 3 - 사용된 모든 바이트-값을 포함하는 문자열이 반환된다. + </simpara> + </listitem> + <listitem> + <simpara> + 4 - 사용되지 않은 보든 바이트-값을 포함하는 문자열이 +반환된다. + </simpara> + </listitem> + </itemizedlist> + </para> + <note> + <para> + 이 함수는 PHP 4.0부터 추가되었다. + </para> + </note> + </refsect1> + </refentry> + <refentry id="function.crc32"> + <refnamediv> + <refname>crc32</refname> + <refpurpose>crc32 다항식의 문자열을 +계산한다</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <function>md5</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.crypt"> + <refnamediv> + <refname>crypt</refname> + <refpurpose>문자열을 DES-암호화 한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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>은 유닉스 표준인 +<abbrev>DES</abbrev> 암호화 기법을 사용하여 문자열을 암호화 한다. + 인수로는 암호화 될 문자열과 선택적으로 +암호화의 기본이 될 두 문자 salt 문자열이 올 수 있다. + 더 많은 정보를 위해 유닉스의 crypt 함수에 +대한 man page를 참조하라. + </para> + <simpara> + 만약 salt 인자가 주어지지 않는다면, PHP에 의해 +무작위로 생성된다. + </simpara> + <simpara> + 몇몇 운영체제는 한가지 타입 이상의 암호화를 +제공한다. 실제로 표준 DES 암호화는 MD5에 기초한 암호화 +알고리즘으로 대체되기도 한다. + 암호화 타입은 slat 인수에 의해 유발된다. +인스톨시, PHP는 암호화 함수의 가용 여부를 결정하고, 다른 +암호화 타입을 위한 salt를 채택할 것이다. + 만약 slat가 제공되지 않으면, PHP는 기본적으로 +두글자 DES salt를 자동 생성하고, 그렇지 않다면 이는 MD5 호환 +salt가 생성되는 경우로 시스템의 기본 암호화 타입은 MD5가 된다. + PHP는 CRYPT_SALT_LENGTH 라는 상수를 설정하는데 +이는 시스템에 2문자 salt를 적용할 것인지 혹은 더 긴 12문자 MD5 +salt를 적용할 것인지를 알려준다. + </simpara> + <simpara> + 만약 제공된 salt를 사용한다면, salt는 한번만 +생성된다는 점을 주의하라. + 만약 이 함수를 재귀적으로 호출한다면, 이는 +겉모습(appearance)과 더쩌면 좀 더 확장된 의미에서 본다면 +보안에도 영향을 끼칠 수도 있다. + </simpara> + <simpara> + 기본적인 DES 암호화인 <function>crypt</function>는 +처음 두 문자가 salt 인 문자열을 출력한다. + </simpara> + <simpara> + crypt() 함수가 다양한 암호화 타입을 지원하는 +시스템에서, 주어진 타입이 가능하느냐에 따라 다음 상수는 0 +이나 1 로 지정된다. + </simpara> + <itemizedlist> + <listitem> + <simpara> + CRYPT_STD_DES - 2-문자 SALT를 가지는 기본 DES 암호화 + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_EXT_DES - 9문자 SALT 를 가지는 확장된 DES 암화화 + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_MD5 - $1$로 시작하는 12문자 SALT를 가지는 MD5 암호화 + </simpara> + </listitem> + <listitem> + <simpara> + CRYPT_BLOWFISH - $2$로 시작하는 16문자 SALT를 갖는 확장된 DES +암호화 + </simpara> + </listitem> + </itemizedlist> + <simpara> + <function>crypt</function>는 one-way 알고리즘을 +사용하므로 decrypt 함수는 존재하지 않는다. + </simpara> + <simpara> + <function>md5</function> 을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.echo"> + <refnamediv> + <refname>echo</refname> + <refpurpose>하나 혹은 그 이상의 문자열을 +출력한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 무돈 인수를 출력한다. + </simpara> + <para> + <function>Echo</function> 는 실제로 함수가 +아니다(이는 하나의 랭귀지 스트럭쳐이다.) 따라서 이 함수와 +함께 parantheses 를 사용할 필요가 없다. + <example> + <title> + <function>Echo</function> 예</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> + 실제로 하나 이상의 인수를 echo 함수에 +전달 하고자 한다면, parentheses 내에서 인수를 괄호로 닫지 +말아야 한다. + In fact, if you want to pass more than one parameter to echo, + you must not enclose the parameters within parentheses. + </para> + </note> + <simpara> + <function>print</function>, + <function>printf</function>, 그리고 + <function>flush</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.explode"> + <refnamediv> + <refname>explode</refname> + <refpurpose>문자열을 주어진 문자열을 기주으로 +분리한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 문자열의 배열을 반환하며, +<parameter>string</parameter>의 부분 문자열로 형성된 각각은 +<parameter>separator</parameter>를 경계로 나누어진다. + <parameter>limit</parameter>가 지정될 경우 반환된 +배열은 마지막 원소가 나머지 문자열의 전체를 포함하는 최대 +<parameter>limit</parameter>개의 엘리먼트를 갖는 배열을 반환한다. + </para> + <note> + <para> + <parameter>limit</parameter> 인수는 PHP +4.0.1 에서 추가되었다. + </para> + </note> + <para> + <example> + <title> + <function>Explode</function> +예</title> + <programlisting role="php"> +$pizza = "piece1 piece2 piece3 piece4 piece5 piece6"; +$pieces = explode (" ", $pizza); + </programlisting> + </example> + </para> + <note> + <para> + 비록 <function>implode</function> 는 관습에 따라 인수의 위치가 +앞 위가 바뀌어도 허용이 되지만, + <function>explode</function> 는 그렇지 못하다. + 반드시 <parameter>separator</parameter> 가 <parameter>string</parameter> +의 앞에 위치해야만 한다. + </para> + </note> + <para> + <function>split</function> 와 + <function>implode</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.get-html-translation-table"> + <refnamediv> + <refname>get_html_translation_table</refname> + <refpurpose> + <function>htmlspecialchars</function> 와 +<function>htmlentities</function>에 사용된 translation 테이블을 반환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string + <function>get_html_translation_table</function> + </funcdef> + <paramdef>int <parameter>table</parameter> + </paramdef> + <paramdef>int <parameter> + +<optional>quote_style</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <function>get_html_translation_table</function> 은 +<function>htmlspecialchars</function> 와 <function>htmlentities</function>에 +내부적으로 사용된 translation 테이블을 반환한다. + 여러분이 원하는 테이블을 지정할 수 +있도록 두가지 새로운 정의(<parameter>HTML_ENTITIES</parameter>, +<parameter>HTML_SPECIALCHARS</parameter>)가 있다. + 그리고 <function>htmlspecialchars</function> 와 + <function>htmlentities</function> 함수에서와 마찬가지로, 선택적으로 +당신이 사용하는 quote_style을 지정할 수 있다. + 기본은 ENT_COMPAT 모드이며, +<function>htmlspecialchars</function>에 설명되어 있는 모드를 참고하기 +바란다. + <example> + <title>Translation 테이블 예</title> + <programlisting role="php"> +$trans = get_html_translation_table (HTML_ENTITIES); +$str = "Hallo & <Frau> & Krämer"; +$encoded = strtr ($str, $trans); + </programlisting> + </example> + <literal>$encoded</literal> 의 값은 다음과 +같다.: "Hallo &<sgmltag>amp</sgmltag>; +&<sgmltag>lt</sgmltag>;Frau&<sgmltag>gt</sgmltag>; + &<sgmltag>amp</sgmltag>; Kr&<sgmltag>auml</sgmltag>;mer". + </para> + <para> + 새로운 방법은 역번역을 하기 위해 +<function>array_flip</function>을 사용하는 것이다. + <informalexample> + <programlisting role="php"> +$trans = array_flip ($trans); +$original = strtr ($str, $trans); + </programlisting> + </informalexample> + The content of <literal>$original</literal> would be: "Hallo & + <Frau> & Krämer". + <note> + <para> + 이 함수는 PHP 4.0 에서 추가되었다. + </para> + </note> + </para> + <para> + 다음을 참고하라 : <function>htmlspecialchars</function>, + <function>htmlentities</function>, <function>strtr</function>, + 그리고 <function>array_flip</function>. + </para> + </refsect1> + </refentry> + <refentry id="function.get-meta-tags"> + <refnamediv> + <refname>get_meta_tags</refname> + <refpurpose> + 화일로 부터 모든 메타 태그 내용 속성을 +배열로 추출한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <parameter>filename</parameter>의 화일을 열고 +<meta>에 해당하는 부분을 줄단위로 해석한다. + <example> + <title>Meta Tags Example</title> + <programlisting role="html"> +<meta name="author" content="name"> +<meta name="tags" content="php3 documentation"> +</head> <!-- 파싱이 여기서 멈춘다. --> + </programlisting> + </example> + (라인 구분에 대해 주의하라 - PHP 입력에 대한 파싱을 할 때 +현재 시스템의 함수를 사용하므로 Mac 에서의 화일이 Unix 에서는 +제대로 동작하지 않을 것이다). + </para> + <para> + 이름 속성에 관한 값은 키가 되며, 콘텐트 속성에 관한 +값은 반환되는 배열의 값이 되어 배열을 다루거나 값을 +접근하는데 손쉽게 기본적인 배열 함수를 사용할 수 있다. + name 속성 값에 있는 특수 문자는 '_'로 치환되며, 나머지는 +소문자로 변환된다. + </para> + <para> + <parameter>use_include_path</parameter> 을 1 로 +세팅하면, PHP 는 화일을 기본 include 경로에서 찾아 열려고 할 +것이다. + </para> + </refsect1> + </refentry> + <refentry id="function.hebrev"> + <refnamediv> + <refname>hebrev</refname> + <refpurpose> + 논리적인 헤브루 텍스트를 알아볼 수 있는 텍스트로 +변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 선택적 인수 <parameter>max_chars_per_line</parameter>는 라인당 +출력될 최대 글자 수를 나타낸다. + 이 함수는 breaking words를 무시하려고 한다.(The function tries to +avoid breaking words.) + </para> + <para> + <function>hebrevc</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.hebrevc"> + <refnamediv> + <refname>hebrevc</refname> + <refpurpose> + 개행 문자를 포함한 헤프류 텍스트를 볼 수 있는 텍스트로 +변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 개행문자(\n) 를 "<br>\n" 로 바꾼다는 것을 +제외하면 <function>hebrev</function>와 비슷하다. + 선택적인 매개변수 <parameter>max_chars_per_line</parameter>는 +출력될 라인당 최대의 문자 수를 가리킨다. + 이 함수는 breaking words를 무시한다.(The function tries to avoid +breaking words.) + </para> + <para> + <function>hebrev</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.htmlentities"> + <refnamediv> + <refname>htmlentities</refname> + <refpurpose> + 해당되는 모든 문자를 HTML 엔터티 형태로 변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string +<function>htmlentities</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + <paramdef>int <parameter> + +<optional>quote_style</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 HTML 엔터티에 해당하는 모든 문자가 HTML +엔터니로 변환된다는 점을 제외하고는 + <function>htmlspecialchars</function> 와 모든 방면에서 일치한다. + <function>htmlspecialchars</function>와 비슷하게 선택적인 두번째의 +인자를 취하는데 이는 + 작은 따옴표와 큰 따옴표를 어떻게 다룰까를 지시한다. + <constant>ENT_COMPAT</constant>(기본값)은 큰따옴표 만을 가꾸고 +작은 따옴표는 내버려 두며, + <constant>ENT_QUOTES</constant>는 작은 따옴표와 큰 따옴표 모드를 +바꾸고, + <constant>ENT_NOQUOTES</constant>는 작은 따옴표와 큰 따옴표 +모두를 바꾸지 않고 그대로 내버려 둔다. + </para> + <para> + 현재 ISO-8859-1 문자 셋이 사용된다. + 선택인자인 두번째 인자는 PHP 3.0.17 과 PHP 4.0.3 에서 +추가되었다. + </para> + <para> + <function>htmlspecialchars</function> 와 + <function>nl2br</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.htmlspecialchars"> + <refnamediv> + <refname>htmlspecialchars</refname> + <refpurpose> + 특수 문자를 HTML 엔터티 형태로 변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string +<function>htmlspecialchars</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + <paramdef>int <parameter> + +<optional>quote_style</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 어떤 문자을은 HTML 내어서 특별한 중요성을 가지며, 그 +문자의 의미를 보존하려면, HTML 엔터티로서 표현되어져야 한다. + 이 함수는 이렇게 만들어진 변환된 문자열을 +반환한다-이러한 번역은 웹 프로그래밍에서 매우 유용하다. + 만약 모든 HTML 문자 엔터티를 번역할 필요가 있다면 +<function>htmlentities</function>를 대신 사용하기 바란다. + </para> + <simpara> + 이 함수는 게시판이나 방명록 등의 프로그램에서 사용자가 +HTML 을 포함하는 텍스트의 사용을 막는데 유용하다. + 선택적인 두번째 인자 quote_style 은 작은 따옴표와 큰 +따옴표를 어떻게 사용할 지를 말해준다. + 기본 모드인 ENT_COMPAT 은 단지 큰 따옴표만 변환하고 작은 +따옴표는 그대로 내버려 둔다. + ENT_QUOTES 가 지정되면, 작은 따옴표와 큰 따옴표 모두를 +번역하며, + ENT_NOQUOTES는 작은 따옴표와 큰 따옴표 모두를 번역하지 +않는다. + </simpara> + <para> + 번역이 이루어지는 형태는 다음과 같다 : + <itemizedlist> + <listitem> + <simpara> + '&' (앰퍼샌드) 는 '&amp;' 이 된다. + </simpara> + </listitem> + <listitem> + <simpara> + '"' (큰따옴표) 는 ENT_NOQUOTES 이 지정되어 있지 않을 때 +'&quot;' 이 된다. + </simpara> + </listitem> + <listitem> + <simpara> + ''' (작은따옴표) 단지 ENT_QUOTES 만 지정괴어 있을 때 +'&#039;' 이 된다. + </simpara> + </listitem> + <listitem> + <simpara> + '<' (보다 작다) 는 '&lt;' 이 된다. + </simpara> + </listitem> + <listitem> + <simpara> + '>' (보다 크다) 는 '&gt;' 이 된다. + </simpara> + </listitem> + </itemizedlist> + <example> + <title> + <function>htmlspecialchars</function> +예</title> + <programlisting role="php"> +$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES); + </programlisting> + </example> + </para> + <para> + 이 함수는 위에 명시된 거 이외에는 어떤 것도 번역하지 +않는다는 것을 명심하라. + 완전한 엔터티 번역을 위해서는 +<function>htmlentities</function>을 참고하라. + 또한 선택적인 두번 째 인자 는 PHP 3.0.17 과 PHP 4.0.3 에서 +추가되었다. + </para> + <para> + <function>htmlentities</function> 와 + <function>nl2br</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.implode"> + <refnamediv> + <refname>implode</refname> + <refpurpose>문자열로 함수 엘리먼트를 +연결한다.</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> + 각각의 배열 요소 사이에 스트링을 포함하는 문자열을 +반환한다. + <example> + <title> + <function>Implode</function> +example</title> + <programlisting role="php"> +$colon_separated = implode (":", $array); + </programlisting> + </example> + </para> + <note> + <para> + <function>implode</function> 는 관습에 +따라 인수의 위치가 앞 위가 바뀌어도 허용이 되지만, + <function>explode</function> 와의 혼란을 막기 위해 이 문서에 +서술된 순서로 인수를 사용하는 것을 권장한다. + </para> + </note> + <simpara> + <function>explode</function>, +<function>join</function>, + 그리고 <function>split</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.join"> + <refnamediv> + <refname>join</refname> + <refpurpose>문자열로 배열의 원소를 +연결한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> 은 +<function>implode</function> 의 별칭이며, 모든 면에서 일치한다. + </simpara> + <simpara> + <function>explode</function>, +<function>implode</function>, + 그리고 <function>split</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.levenshtein"> + <refnamediv> + <refname>levenshtein</refname> + <refpurpose> + 두 문자열 간의 Levenshtein 디스턴스를 계산한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>levenshtein</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + <funcprototype> + <funcdef>int <function>levenshtein</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + <paramdef>int <parameter>cost_ins</parameter> + </paramdef> + <paramdef>int <parameter>cost_rep</parameter> + </paramdef> + <paramdef>int <parameter>cost_del</parameter> + </paramdef> + </funcprototype> + <funcprototype> + <funcdef>int <function>levenshtein</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + <paramdef>function <parameter>cost</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + This function returns the Levenshtein-Distance between the + two argument strings or -1, if one of the argument strings + is longer than the limit of 255 characters (255 should be + more than enough for name or dictionary comparison, and + nobody serious would be doing genetic analysis with PHP). + </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> + In its simpelest form the function will take only the two + strings as parameter and will calculate just the number of + insert, replace and delete operations needed to transform + <parameter>str1</parameter> into <parameter>str2</parameter>. + </para> + <para> + A second variant will take three additional parameters that + define the cost of insert, replace and delete operations. + This is more general and adaptive than variant one, but not + as efficient. + </para> + <para> + The third variant (which is not implemented yet) will be + the most general and adaptive, but also the slowest alternative. + It will call a user-supplied function that will determine the + cost for every possible operation. + </para> + <para> + The user-supplied function will be called with the following + arguments: + <itemizedlist> + <listitem> + <simpara> + operation to apply: 'I', 'R' or 'D' + </simpara> + </listitem> + <listitem> + <simpara> + actual character in string 1 + </simpara> + </listitem> + <listitem> + <simpara> + actual character in string 2 + </simpara> + </listitem> + <listitem> + <simpara> + position in string 1 + </simpara> + </listitem> + <listitem> + <simpara> + position in string 2 + </simpara> + </listitem> + <listitem> + <simpara> + remaining characters in string 1 + </simpara> + </listitem> + <listitem> + <simpara> + remaining characters in string 2 + </simpara> + </listitem> + </itemizedlist> + The user-supplied function has to return a positive integer + describing the cost for this particular operation, but it + may decide to use only some of the supplied arguments. + </para> + <para> + The user-supplied function approach offers the possibility to + take into account the relevance of and/or difference between + certain symbols (characters) or even the context those symbols + appear in to determine the cost of insert, replace and delete + operations, but at the cost of loosing all optimizations done + regarding cpu register utilization and cache misses that have + been worked into the other two variants. + </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> + 문자열 시작부분에서 공백을 제거한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ltrim</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 문자열 앞부분의 공백을 제거하며, 공백 제거된 +문자열을 반환한다. + 일반적으로 제거되는 문자는 다음과 같다 : "\n", "\r", "\t", +"\v", "\0", 그리고 공백 + </para> + <para> + <function>chop</function>, <function>rtrim</function>, +그리고 + <function>trim</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.md5"> + <refnamediv> + <refname>md5</refname> + <refpurpose>문자열의 md5 해쉬를 +계산한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>md5</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <ulink url="&url.rfc;rfc1321.html">RSA Data Security, +Inc. MD5 Message-Digest Algorithm</ulink>을 사용하여 + <parameter>str</parameter>의 MD5 해쉬를 계산한다. + </para> + <para> + <function>crc32</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.metaphone"> + <refnamediv> + <refname>Metaphone</refname> + <refpurpose>문자열의 메타폰 키(metaphone key) 를 +계산한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>metaphone</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str</parameter>의 메타폰 키(metaphone +key) 를 계산한다. + </para> + <para> + <function>soundex</function>와 비슷하게 +메타폰(metaphone)은 유사한 발음의 단어에 대한 동일한 키를 +생성한다. + 이 함수는 영어 발음의 기본 법칙을 +사용하는<function>soundex</function>보다 훨씬 정확하다. + 메타폰 생성 키는 가변길이이다. + </para> + <para> + 메타폰은 Lawrence Philips <[EMAIL PROTECTED]>에 의해 +개발되었다. + 이는 ["Practical Algorithms for Programmers", Binstock & Rex, Addison +Wesley, 1995]에 서술되어 있다. + <note> + <para> + 이 함수는 PHP 4.0 에서 추가되었다. + </para> + </note> + </para> + </refsect1> + </refentry> + <refentry id="function.nl2br"> + <refnamediv> + <refname>nl2br</refname> + <refpurpose>뉴라인을 HTML 라인 +브레이크(<BR>)로 변환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>nl2br</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 뉴 라인 전에 '<BR>' 가 삽입된 <parameter>string</parameter>을 +반환한다. + </para> + <para> + <function>htmlspecialchars</function>, + <function>htmlentities</function> 그리고 + <function>wordwrap</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.ord"> + <refnamediv> + <refname>Ord</refname> + <refpurpose>문자의 ASCII 값을 반환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>ord</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>string</parameter>의 첫번째 문자의 +ASCII 값을 반환한다. + 이 함수는 <function>chr</function>을 보충한다. + <example> + <title> + <function>Ord</function> 예</title> + <programlisting role="php"> +if (ord ($str) == 10) { + echo "The first character of \$str is a line feed.\n"; +} + </programlisting> + </example> + </para> + <simpara> + <function>chr</function>을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.parse-str"> + <refnamediv> + <refname>parse_str</refname> + <refpurpose>문자열을 변수로 파싱한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>parse_str</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + <paramdef>array <parameter> + <optional>arr</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 문자열 <parameter>str</parameter>을 마치 URL을 통해 온 +질의문인것 처럼 파싱하고 + 전역 변수로 변수를 지정한다. + 만약 두번째 매개변수 <parameter>arr</parameter>이 존재하면, + 변수는 <parameter>arr</parameter>이름을 갖는 배열의 원소로 +저장된다. + </para> + <para> + <example> + <title> + <function>parse_str</function>의 +사용 + </title> + <programlisting role="php"> +$str = "first=value&second[]=this+works&second[]=another"; +parse_str($str); +echo $first; /* "value" 를 출력 */ +echo $second[0]; /* "this works" 를 출력 */ +echo $second[1]; /* "another" 를 출력 */ + </programlisting> + </example> + </para> + </refsect1> + </refentry> + <refentry id="function.print"> + <refnamediv> + <refname>print</refname> + <refpurpose>문자열을 출력한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef> + <function>print</function> + </funcdef> + <paramdef>string <parameter>arg</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <parameter>arg</parameter>을 출력한다. + </simpara> + <simpara> + <function>echo</function>, <function>printf</function>, + 그리고 <function>flush</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.printf"> + <refnamediv> + <refname>printf</refname> + <refpurpose>포멧된 문자열을 출력한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <parameter>format</parameter>에 따라 출력을 +만들어 내며, 이는 <function>sprintf</function>를 위한 문서에 +설명되어 있다. + </simpara> + <simpara> + <function>print</function>, +<function>sprintf</function>, + <function>sscanf</function>, <function>fscanf</function>, + 그리고 <function>flush</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.quoted-printable-decode"> + <refnamediv> + <refname>quoted_printable_decode</refname> + <refpurpose> + 인용된 출력가능한 문자열을 8비트 문자열로 변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string + <function>quoted_printable_decode</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + 이 함수는 디코드된 인용된 출력 가능한 문자열에 +해당하는 8비트 바이너리 문자열을 반환한다. + 이 함수는 작동하는데 IMAP 모듈이 필요 없다는 점을 +제외하면, <function>imap_qprint</function>와 유사하다. + </simpara> + </refsect1> + </refentry> + <refentry id="function.quotemeta"> + <refnamediv> + <refname>quotemeta</refname> + <refpurpose>메타 문자를 인용한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>quotemeta</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <screen>. \\ + * ? [ ^ ] ( $ )</screen>의 문자들 +전에 + <parameter>str</parameter>의 백슬래쉬 문자(<literal>\</literal>) 를 +사용한 버젼을 반환한다. + </para> + <simpara> + <function>addslashes</function>, + <function>htmlentities</function>, + <function>htmlspecialchars</function>, + <function>nl2br</function>, 그리고 + <function>stripslashes</function>을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.rtrim"> + <refnamediv> + <refname>rtrim</refname> + <refpurpose>문자열 끝의 공백을 +제거한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcdef>string <function>rtrim</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcsynopsis> + <para> + 인수로 넘어온 문자열에서 뉴라인을 포함하는 문자열 끝의 +공백을 제거한 문자열을 반환 하며, + 이는 <function>chop</function>의 별칭이다. + <example> + <title> + <function>rtrim</function> 예</title> + <programlisting role="php"> +$trimmed = rtrim ($line); + </programlisting> + </example> + </para> + <para> + <function>trim</function>, <function>ltrim</function>, +그리고 + <function>rtrim</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.sscanf"> + <refnamediv> + <refname>sscanf</refname> + <refpurpose>포멧이 따라서 입력을 문자열로부터 +파싱한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <function>sscanf</function> 함수는 +<function>printf</function>의 입력 유사성을 가진다. + <function>Sscanf</function>sms <parameter>str</parameter> 문자열로 부터 +입력을 읽어 + 특정한 <parameter>format</parameter> 에 따라 인터럽트한다. + - <function>Sscanf</function> reads from the string +<parameter>str</parameter> + and interprets it according to the specified <parameter>format</parameter>. + 만약 두개의 매개변수만이 이 함수로 전달된다면, 파싱된 +값은 배열로서 반환된다. + <example> + <title> + <function>Sscanf</function> 예</title> + <programlisting role="php"> +// 시리얼 번호를 얻는다. +$serial = sscanf("SN/2350001","SN/%d"); +// 제조일을 지정한다. +$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> + 선택적인 매개변수가 전달되면, 함수는 할당된 값에 대한 +수를 반환한다. + 선택적인 매개변수는 반드시 참조에 의해 전달되어야 한다. + <example> + <title> + <function>Sscanf</function> - +선택적인 매개변수 사용하기</title> + <programlisting role="php"> +// 작가 정보를 얻고 DocBook의 인트리를 활성화한다. +$auth = "24\tLewis Carroll"; +$n = sscanf($auth,"%d\t%s %s", &$id, &$first, &$last); +echo "<author id='$id'> + <firstname>$first</firstname> + <surname>$last</surname> +</author>\n"; + </programlisting> + </example> + </para> + <para> + <function>fscanf</function>, +<function>printf</function>, + 그리고 <function>sprintf</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.setlocale"> + <refnamediv> + <refname>setlocale</refname> + <refpurpose>지역적보를 지정한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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>는 지역 세팅에 +의해 영향을 받는 함수의 범주를 특성화 하는 문자열이다 : + <itemizedlist> + <listitem> + <simpara> + LC_ALL - 이후 나오는 모든 것을 위해 + </simpara> + </listitem> + <listitem> + <simpara> + LC_COLLATE - 문자열 비교를 위함 - 통상적으로 PHP에서는 +실핻외지 않는다 + </simpara> + </listitem> + <listitem> + <simpara> + LC_CTYPE - <function>strtoupper</function>와 같이 문자 정형화와 +변환을 위해. + </simpara> + </listitem> + <listitem> + <simpara> + LC_MONETARY - localeconv() 를 위해 - 통상적으로 PHP에서는 +실핻외지 않는다 + </simpara> + </listitem> + <listitem> + <simpara> + LC_NUMERIC - 십진 구분자를 위해 + </simpara> + </listitem> + <listitem> + <simpara> + LC_TIME - <function>strftime</function>와 함께 날자와 시간 +표매팅을 위해 + </simpara> + </listitem> + </itemizedlist> + </para> + <para> + 만약 <parameter>locale</parameter>이 빈 문자열 <literal>""</literal>일 +경우 + 로케일 이름은 위 카타고리의 이름과 같은 이름을 갖는 +환경변수나 "LANG"으로 부터 세팅된다. + </para> + <para> + 만약 로케일이 0 이거나 문자 <literal>"0"</literal>일 경우, + 로케일 세팅은 영향을 받지 않고 단지 현재의 설정만이 +반환된다. + </para> + <para> + Setlocale 은 새로운 현재 로케일이나, 로케일 기능이 +플랫폼이서 수행되지 않거나, + 특정 로케일이 존재하지 않거나 혹은 카테고리 이름이 +유효하지 않을 경우 거짓을 반환한다. + 유효하지 않은 카테고리 이름 역시 경고 메시지를 +야기시킨다. + </para> + </refsect1> + </refentry> + <refentry id="function.similar-text"> + <refnamediv> + <refname>similar_text</refname> + <refpurpose> + 두 문자열 간의 유사성을 계산한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이는 Oliver [1993]에 설명된 것처럼 두 문자열 간의 유사성을 +계산한다. + 이 수행은 Oliver's 의사코드에서 처럼 스택을 사용하는 +것이 아니라, + 전체 프로세스에서 속도를 높이거나 느리게 할 수도 있는 +재귀적인 호출을 + 사용함을 주의하라. + 또한 이 알고리즘의 복잡도는 O(N**3) 이며 N은 가장 긴 +문자열의 길이를 나타낸다. + </para> + <para> + 세번째 인자는 참조에 의한 전달을 함으로서, +<function>similar_text</function>는 + 두 문자열간의 유사성을 퍼센티지로 계산할 수 있다. + 이 함수는 두 문자열의 매칭하는 문자 수를 리턴한다. + </para> + </refsect1> + </refentry> + <refentry id="function.soundex"> + <refnamediv> + <refname>soundex</refname> + <refpurpose>문자열의 soundex 키를 +계산한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>soundex</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str</parameter>의 soundex키를 +계산한다. + </para> + <para> + Soundex 키는 단어의 발음이 같으면, 같은 soundex 키를 +생성하는 특성을 가진다. + 그리고 이로인해 데이타베이스에서 발음은 알지만 스펠을 +모르는 단어를 쉽게 찾을 수 가 있다. + 이 soundex 함수는 알파벳 문자로 시작하는 4 문자 길이의 +문자열을 반환한다. + </para> + <para> + 이렇게 특별한 soundex 함수는 "The Art Of Computer Programming, vol. +3: Sorting And + Searching", Addison-Wesley (1973), pp. 391-392 에서 Donald Knuth 에 의해 +기술되었다. + </para> + <para> + <example> + <title>Soundex 예</title> + <programlisting role="php"> +soundex ("Euler") == soundex ("Ellery") == 'E460'; +soundex ("Gauss") == soundex ("Ghosh") == 'G200'; +soundex ("Hilbert") == soundex ("Heilbronn") == 'H416'; +soundex ("Knuth") == soundex ("Kant") == 'K530'; +soundex ("Lloyd") == soundex ("Ladd") == 'L300'; +soundex ("Lukasiewicz") == soundex ("Lissajous") == 'L222'; + </programlisting> + </example> + </para> + </refsect1> + </refentry> + <refentry id="function.sprintf"> + <refnamediv> + <refname>sprintf</refname> + <refpurpose>포멧된 문자열을 반환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 포맷 문자인<parameter>format</parameter>에 따라서 생성된 +문자열을 반환한다. + <parameter>format</parameter>. + </simpara> + <simpara> + 포맷 스트링은 0 혹은 다른 지시문이 올 수 있다: + 직접 결과로 복사된는 일반적인 문자(<literal>%</literal>을 +포함하여)와 + <emphasis>변환 특수 문자(conversion specifications)</emphasis>, + 각각은 자신의 매개변수를 패치하는 결과를 나타낸다. + 이는 <function>sprintf</function> 와 <function>printf</function> +두두에서도 마찬가지이다. + </simpara> + <para> + 각각 변환 특수문자는 퍼센트 기호(<literal>%</literal>) 로 +구성되며, + 차례 차례로 다음의 요소가 하나 혹은 여러개 따라온다 : + <orderedlist> + <listitem> + <simpara> + + 선택적인 <emphasis>패딩 지정자(padding specifier)</emphasis>는 +결과로 문자열 오른쪽에 그 정해진 + 크기만큼 패딩을 가하는데 사용되며, 이는 공백 문자 +일 수도 있고, <literal>0</literal>(0 문자)일 수 도 있다. + 기본은 공백으로 패딩되며, 다른 패딩 문자가 작은 +따옴표 (<literal>'</literal>)와 함께 앞에 붙어 지정되어 질 + 수도 있다. + 아래의 예를 보라. + </simpara> + </listitem> + <listitem> + <simpara> + 선택적인 <emphasis>정렬 지정자(alignment +specifier)</emphasis>는 결과 문자열이 왼쪽 정렬될 것인지 + 오른쪽 정렬 될 것인지를 결정하며, 기본은 오른쪽 +정렬이다; <literal>-</literal>문자는 왼쪽 정렬로 만든다. + </simpara> + </listitem> + <listitem> + <simpara> + 선택적인 숫자 <emphasis>폭 지정자(width +specifier)</emphasis>는 + (최소) 얼마나 많은 문자들을 이 변환이 결과로 낼 +것인가를 말해준다. + </simpara> + </listitem> + <listitem> + <simpara> + 선택적인 <emphasis>정밀도 지시자(precision +specifier)</emphasis>는 + 얼마나 많은 십진 숫자가 소수점 이하의 수로서 +표시될 것인가를 지정한다. + 이 옵션은 double 형에서만 유효하다.(숫자를 포메팅 +하는데 있어서 유용한 + 다른 함수로 <function>number_format</function>이 있다.) + </simpara> + </listitem> + <listitem> + <para> + <emphasis>형 지시자(type +specifier)</emphasis>는 인수 데이타가 적용될 형식을 지정한다. + 가능한 타입으로는 : + <simplelist> + <member> + +<literal>%</literal> - 리터럴 퍼센트 문자. 어떤 인수도 필요하지 +않다. + </member> + <member> + +<literal>b</literal> - 인수는 정수처럼 처리되며, 십진수로 표현된다. + </member> + <member> + +<literal>c</literal> - 인수는 정수처럼 처리되며, 그 숫자의 +ASCII코드에 해당하는 문자로 표현된다. + </member> + <member> + +<literal>d</literal> - 인수는 정수처럼 처리되며, 10진수로 표현된다. + </member> + <member> + +<literal>f</literal> - 인수는 더블형으로 처리되며, 수숫점을 +가지는 실수 숫자로 표현된다. + </member> + <member> + +<literal>o</literal> - 인수는 정수로 처리되며, 8진수 형태로 +표현된다. + </member> + <member> + +<literal>s</literal> - 인수는 문자열로 처리, 표현된다. + </member> + <member> + +<literal>x</literal> - 인수는 정수로 처리되며, (소문자로 +표시되는)16진수로 표현된다. + </member> + <member> + +<literal>X</literal> - 인수는 정수로 처리되며, (대문자로 +표시되는)16진수로 표현된다. + </member> + </simplelist> + </para> + </listitem> + </orderedlist> + </para> + <simpara> + <function>printf</function>, +<function>sscanf</function>, + <function>fscanf</function>, 그리고 <function>number_format</function>를 +참고하라. + </simpara> + </refsect1> + <refsect1> + <title>예</title> + <para> + <example> + <title> + <function>Sprintf</function>: 0으로 +채워진 정수</title> + <programlisting role="php"> +$isodate = sprintf ("%04d-%02d-%02d", $year, $month, $day); + </programlisting> + </example> + <example> + <title> + <function>Sprintf</function>: +통화의 포맷</title> + <programlisting role="php"> +$money1 = 68.75; +$money2 = 54.35; +$money = $money1 + $money2; +// echo $money는 "123.1" 을 출력; +$formatted = sprintf ("%01.2f", $money); +// echo $formatted 는 output "123.10"을 출력 + </programlisting> + </example> + </para> + </refsect1> + </refentry> + <refentry id="function.strncasecmp"> + <refnamediv> + <refname>strncasecmp</refname> + <refpurpose> + 대소문자를 분하지 않는 2진수 형태의 문자열의 처음 n 개 +문자를 비교 - + Binary safe case-insensitive string comparison of the first n characters + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strncasecmp</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + <paramdef>int <parameter>len</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 <function>strcasecmp</function>와 비슷하며 차이라면, + 비교에 사용 될 각각의 문자열로 부터 비교할 문자의 수 +(<parameter>len</parameter>)를 + 지정할 수 있다는 것이다. + 둘 중 하나의 문자열이 (<parameter>len</parameter>보다 짧다면, +짧은 문자열의 길이가 + 두 문자열을 비교하는 데 사용된다. + </para> + <simpara> + <parameter>str1</parameter>이 +<parameter>str2</parameter>보다 작다면 < 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + </simpara> + <simpara> + <function>ereg</function>, +<function>strcasecmp</function>, + <function>strcmp</function>, <function>substr</function>, + <function>stristr</function>, 그리고 <function>strstr</function>을 +참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strcasecmp"> + <refnamediv> + <refname>strcasecmp</refname> + <refpurpose> + 대소문자를 구분하지 않는 2진수 형태의 문자열을 비교 +(Binary safe case-insensitive string comparison) + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcasecmp</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str1</parameter>이 +<parameter>str2</parameter>보다 작다면 < 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + <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> + <function>ereg</function>, <function>strcmp</function>, + <function>substr</function>, <function>stristr</function>, + <function>strncasecmp</function>, 그리고 <function>strstr</function>을 +참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strchr"> + <refnamediv> + <refname>strchr</refname> + <refpurpose> + 문자가 처음 나타난 위치를 찾는다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strchr</function> + </funcdef> + <paramdef>string +<parameter>haystack</parameter> + </paramdef> + <paramdef>string <parameter>needle</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 <function>strstr</function>의 별칭이며, 모든 방면에서 +동일하다. + </para> + </refsect1> + </refentry> + <refentry id="function.strcmp"> + <refnamediv> + <refname>strcmp</refname> + <refpurpose>2진 형태의 문자열을 비교</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcmp</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <parameter>str1</parameter>이 +<parameter>str2</parameter>보다 작다면 < 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + </simpara> + <simpara> + 이 비교는 대소문자를 비교함을 주의하라. + </simpara> + <simpara> + <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strncasecmp</function>, + <function>strncmp</function>, 그리고 <function>strstr</function>을 +참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strcspn"> + <refnamediv> + <refname>strcspn</refname> + <refpurpose> + 마스크와 매칭되지 않는 초기 세그먼트의 길이 찾는다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strcspn</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <parameter>str2</parameter> 내의 어떤 문자도 +포함하지 <emphasis>않는</emphasis> + <parameter>str1</parameter>의 초기 세그먼트의 +길이를 반환한다. + </simpara> + <simpara> + <function>strspn</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strip-tags"> + <refnamediv> + <refname>strip_tags</refname> + <refpurpose>문자열로 부터 HTML 태그와 PHP 태그를 +없앤다</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 모든 HTML과 PHP 태그를 주어진 문자열로 부터 +제거한다. + 완전하지 못하거나 보거스 태그 같은 경우에 어러는 낸다. + <function>fgetss</function> 함수에서 처럼 같태그 제거 state +머신을 사용한다. + </para> + <para> + 선택적으로 두번째 인수를 사용하여 제거되지 않을 +태그를 지정할 수도 있다. + <note> + <para> + <parameter>Allowable_tags</parameter> +는 PHP 3.0.13, PHP4B3 에서 추가되었다. + </para> + </note> + </para> + </refsect1> + </refentry> + <refentry id="function.stripcslashes"> + <refnamediv> + <refname>stripcslashes</refname> + <refpurpose> + <function>addcslashes</function>로 quote 된 +문자열을 un-quote 한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string +<function>stripcslashes</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 백슬래쉬가 제거된 문자열을 반환한다. + C 형식의 <literal>\n</literal>, <literal>\r</literal> ... 8진수 그리고 +16진수 표현도 인식한다. + <note> + <simpara> + PHP4b3-dev 에서 추가되었다. + </simpara> + </note> + </para> + <simpara> + <function>addcslashes</function>를 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.stripslashes"> + <refnamediv> + <refname>stripslashes</refname> + <refpurpose> + <function>addslashes</function>로 quote 된 +문자열을 un-quote 한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string +<function>stripslashes</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 백슬래쉬가 제거된 문자열을 반환한다. + (<literal>\'</literal> 는 <literal>'</literal> 로 되는 등.) + 이중 백슬래쉬는 하나의 백슬래쉬로 변환된다. + </para> + <simpara> + <function>addslashes</function>을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.stristr"> + <refnamediv> + <refname>stristr</refname> + <refpurpose> + 대소문자를 구별하지 않는 <function>strstr</function> + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>stristr</function> + </funcdef> + <paramdef>string +<parameter>haystack</parameter> + </paramdef> + <paramdef>string <parameter>needle</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>needle</parameter>의 처음 발생 부터 +끝날 때 까지 + 모든 <parameter>haystack</parameter>를 반환한다. + <parameter>needle</parameter> 과 <parameter>haystack</parameter>은 + 대소문자를 구별하지 않고 검사된다. + </para> + <para> + 만약<parameter>needle</parameter> 이 발견되지 않으면 false 를 +반환한다. + </para> + <para> + 만약 <parameter>needle</parameter>이 문자열이 아니면, 이는 숫자로 +변환되고 + 문자의 순서값처럼 적용된다. + </para> + <para> + <function>strchr</function>, + <function>strrchr</function>, <function>substr</function>, 그리고 + <function>ereg</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strlen"> + <refnamediv> + <refname>strlen</refname> + <refpurpose>문자열의 길이를 구한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strlen</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>string</parameter>문자열의 길이를 +반환한다. + </para> + </refsect1> + </refentry> + <refentry id="function.strnatcmp"> + <refnamediv> + <refname>strnatcmp</refname> + <refpurpose> + "natural order" 알고리즘을 이용한 문자열 비교 + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strnatcmp</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 으로 사람이 하는것과 같은 알파벳과 숫자를 +정렬하는 방법의 비교 알고리즘을 수행한다. + 이 알고리즘과 컴퓨터가 사용하는 정렬 +알고리즘(<function>strcmp</function>에 사용)과의 차이가 + 아래의 예에 나와 있다.: + <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> + 위의 코드는 아래의 결과를 생성할 것이다.: + <informalexample> + <programlisting> +기본 문자열 비교(Standard string comparison) +Array +( + [0] => img1.png + [1] => img10.png + [2] => img12.png + [3] => img2.png +) + +Natural order 문자열 비교 +Array +( + [0] => img1.png + [1] => img2.png + [2] => img10.png + [3] => img12.png +) + </programlisting> + </informalexample> + 더 많은 정보를 위해 Martin Pool 의 <ulink +url="&url.strnatcmp;">Natural Order String Comparison</ulink> + 을 참고하라. + </para> + <simpara> + 문자열 비교 함수와 비슷하게 이 함수는, + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 작다면 +< 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + </simpara> + <simpara> + 이 비교는 대소문자를 구별함을 유의해라. + </simpara> + <simpara> + <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + <function>strncmp</function>, <function>strncasecmp</function>, + <function>strnatcasecmp</function>, <function>strstr</function>, + <function>natsort</function> 그리고 <function>natcasesort</function>를 +참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strnatcasecmp"> + <refnamediv> + <refname>strnatcasecmp</refname> + <refpurpose> + 대소문자 구별 없이 "natural order" 알고리즘으로 문자열을 +비교한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strnatcasecmp</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 으로 사람이 하는것과 같은 알파벳과 숫자를 +정렬하는 방법의 비교 알고리즘을 수행한다. + 이 함수의 작용은 <function>strnatcmp</function> 와 +비슷하며, + 대소문자를 구분하지 않는다는 데에서 차이가 난다. + 더 많은 정보를 위해 Martin Pool 의 <ulink +url="&url.strnatcmp;">Natural Order String Comparison</ulink> + 을 참고하라. + </para> + <simpara> + 문자열 비교 함수와 비슷하게 이 함수는, + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 작다면 +< 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + </simpara> + <simpara> + <function>ereg</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + <function>strncmp</function>, <function>strncasecmp</function>, + <function>strnatcmp</function>, 그리고 <function>strstr</function>을 +참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strncmp"> + <refnamediv> + <refname>strncmp</refname> + <refpurpose> + 처음 n 문자의 binary safe 문자열 비교 + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 <function>strcmp</function>비 비슷하며, + 비교에 사용 될 각각의 문자열로 부터 비교할 문자의 수 +(<parameter>len</parameter>)를 + 지정할 수 있다는 것에 차이가 있다. + 둘 중 하나의 문자열이 (<parameter>len</parameter>보다 짧다면, +짧은 문자열의 길이가 + 두 문자열을 비교하는 데 사용된다. + </para> + <simpara> + <parameter>str1</parameter>이 +<parameter>str2</parameter>보다 작다면 < 0 을 반환하고; + <parameter>str1</parameter>이 <parameter>str2</parameter>보다 크다면 +> 0 을 반환한다. + 그리고 이들이 같다면 0을 반환한다. + </simpara> + <simpara> + 이 비교는 대소문자를 구분한다는 것에 유의하라. + </simpara> + <simpara> + <function>ereg</function>, +<function>strncasecmp</function>, + <function>strcasecmp</function>, <function>substr</function>, + <function>stristr</function>, <function>strcmp</function>, + 그리고 <function>strstr</function>을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.str-pad"> + <refnamediv> + <refname>str_pad</refname> + <refpurpose>다른 문자로 특정 길이만큼 문자열을 +채운다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 <parameter>input</parameter>문자열에 왼쪽, 오른쪽, +혹은 양방향으로 특정한 패딩 길이만큼 채운다. + 만약 선택적인 매개변수 <parameter>pad_string</parameter>가 +제공되지 않는다면, + <parameter>input</parameter>는 공백으로 채워지며, 그렇지 않을 +경우 + 그 한계까지 <parameter>pad_string</parameter>로 부터의 문자를 +채우게 된다. + </para> + <para> + 선택적인 매개변수 <parameter>pad_type</parameter>로는 + STR_PAD_RIGHT, STR_PAD_LEFT, 혹은 STR_PAD_BOTH 가 올 수 있다. + <parameter>pad_type</parameter>가 지정되지 않으면 STR_PAD_RIGHT 로 +여겨진다. + </para> + <para> + <parameter>pad_length</parameter>의 값이 음의 +값이거나 입력 문자열의 길이보다 작을 경우 + 패딩은 일어나지 않는다. + </para> + <para> + <example> + <title> + <function>str_pad</function> +예</title> + <programlisting role="php"> +$input = "Alien"; +print str_pad($input, 10); // "Alien " 이 생성된다. +print str_pad($input, 10, "-=", STR_PAD_LEFT); // "-=-=-Alien" 이 생성된다. +print str_pad($input, 10, "_", STR_PAD_BOTH); // "__Alien___" 이 생성된다. + </programlisting> + </example> + </para> + </refsect1> + </refentry> + <refentry id="function.strpos"> + <refnamediv> + <refname>strpos</refname> + <refpurpose> + 문자열에서 처음 위치를 반환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <parameter>haystack</parameter> 문자열에서 처음 +나타나는 + <parameter>needle</parameter> 의 위치를 숫자로 반환한다. + <function>strrpos</function>와 틀리게 이 함수는 + <parameter>needle</parameter> 매개변수 로 전체 문자열을 사용할 +수 있으며, + 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> + <parameter>needle</parameter> 이 발견되지 +않으면 거짓을 반환한다. + <note> + <para> + "0번째 위치에서 발견된 문자"에 대한 값과 문자가 +발견되지 않았을 경우에 반환되는 값에 대해 + 실수를 범하기 쉽다. + 여기 이 차이점을 간파하는 방법이 있다.: + <informalexample> + <programlisting role="php"> +// PHP 4.0b3 이상에서: +$pos = strpos ($mystring, "b"); +if ($pos === false) { // note: === 을 사용 + // 발견되지 않음 +} + +// PHP 4.0b3 이전의 버젼에서: +$pos = strpos ($mystring, "b"); +if (is_string ($pos) && !$pos) { + // 발견되지 않음 +} + </programlisting> + </informalexample> + </para> + </note> + </para> + <para> + <parameter>needle</parameter>이 문자열이 +아니라면, + 이는 숫자로 변환되고 문자의 서열 값(ordinal value)으로서 +적용된다. + </para> + <para> + 선택적인 <parameter>offset</parameter> 매개변수는 + <parameter>haystack</parameter>에 있는 어떤 문자부터 찾기 시작할 +지를 지정할 수 있게 해 준다. + 반환되는 위치는 <parameter>haystack</parameter> 을 시작으로 하는 +상대적인 위치가 된다. + </para> + <para> + <function>strrpos</function>, + <function>strrchr</function>, <function>substr</function>, + <function>stristr</function>, 그리고 <function>strstr</function>를 +참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strrchr"> + <refnamediv> + <refname>strrchr</refname> + <refpurpose> + 문자열에서 가장 마지막의 어커런스를 찾는다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strrchr</function> + </funcdef> + <paramdef>string +<parameter>haystack</parameter> + </paramdef> + <paramdef>string <parameter>needle</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 <parameter>haystack</parameter>의 일부를 반환하는데, + 이는 <parameter>needle</parameter>의 마지막 어커런스에서 +시작하고 + <parameter>haystack</parameter>의 끝까지 진행된다. + </para> + <para> + <parameter>needle</parameter>이 발견되지 +않으면, 거짓을 반환한다. + </para> + <para> + <parameter>needle</parameter>이 한문자 이상을 +포함하고 있으면, + 첫번째 문자가 사용된다. + </para> + <para> + <parameter>needle</parameter>이 문자열이 +아니라면, + 숫자로 변환되어 문자의 서열값(ordinal value) 로서 적용된다. + <example> + <title> + <function>Strrchr</function> +예</title> + <programlisting role="php"> +// $PATH 안에서 마지막 디렉토리를 얻는다. +$dir = substr (strrchr ($PATH, ":"), 1); + +// 마지막 뉴라인 다음의 문자열을 얻는다. +$text = "Line 1\nLine 2\nLine 3"; +$last = substr (strrchr ($text, 10), 1 ); + </programlisting> + </example> + </para> + <para> + <function>substr</function>, + <function>stristr</function>, 그리고 <function>strstr</function>을 +참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.str-repeat"> + <refnamediv> + <refname>str_repeat</refname> + <refpurpose>문자열을 반복한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <parameter>input_str</parameter>을 +<parameter>multiplier</parameter>번 반복해서 반환한다. + <parameter>multiplier</parameter>는 반드시 0보다 커야 한다. + </para> + <example> + <title> + <function>Str_repeat</function> 예</title> + <programlisting role="php"> +echo str_repeat ("-=", 10); + </programlisting> + </example> + <para> + This will output "-=-=-=-=-=-=-=-=-=-=". + </para> + <note> + <para> + 이 함수는 PHP 4.0 에서 추가되었다. + </para> + </note> + </refsect1> + </refentry> + <refentry id="function.strrev"> + <refnamediv> + <refname>strrev</refname> + <refpurpose>문자열을 뒤집는다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strrev</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 역으로 된 <parameter>string</parameter>을 반환한다. + </para> + </refsect1> + </refentry> + <refentry id="function.strrpos"> + <refnamediv> + <refname>strrpos</refname> + <refpurpose> + 문자열 안에서 문자의 마지막 출현 위치를 반환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strrpos</function> + </funcdef> + <paramdef>string +<parameter>haystack</parameter> + </paramdef> + <paramdef>char <parameter>needle</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>haystack</parameter>문자열에서 + <parameter>needle</parameter>의 마지막 출현 위치를 + 숫자로 반환한다. + 이 경우의 needle은 단지 단일 문자만 가능하다는 것을 +명심하라. + 만약 문자열이 needle로서 전달된다면, 오직 그 문자열의 +첫번째 문자만이 사용된다. + </para> + <para> + <parameter>needle</parameter>이 발견되지 +않으면, 거짓을 반환한다. + <note> + <para> + 일어나기 쉬운 실수 중의 하나는 "위치 0이서 문자가 +발견"된 경우 와 + "문자가 발견되지 않은 경우"에 대한 반환값이다. + 여기 이 차이를 발견하는 방법이 있다.: + <informalexample> + <programlisting role="php"> +// PHP 4.0b3 이상에서: +$pos = strrpos ($mystring, "b"); +if ($pos === false) { // note: === 사용 + // 발견되지 않음 +} + +// 버젼 4.0b3 이하에서: +$pos = strrpos ($mystring, "b"); +if (is_string ($pos) && !$pos) { + // 발견되지 않음 +} + </programlisting> + </informalexample> + </para> + </note> + </para> + <para> + <parameter>needle</parameter>이 문자열이 +아니라면, + 숫자로 변환되어 문자의 서열값(ordinal value) 로서 적용된다. + </para> + <para> + <function>strpos</function>, + <function>strrchr</function>, <function>substr</function>, + <function>stristr</function>, 그리고 <function>strstr</function>을 +참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strspn"> + <refnamediv> + <refname>strspn</refname> + <refpurpose> + 마스크에 매칭되는 초기 세그먼트의 길이를 찾는다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>strspn</function> + </funcdef> + <paramdef>string <parameter>str1</parameter> + </paramdef> + <paramdef>string <parameter>str2</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <parameter>str2</parameter> 내의 어떤 문자도 +포함하는 + <parameter>str1</parameter>의 초기 세그먼트의 길이를 반환한다. + </simpara> + <para> + <informalexample> + <programlisting role="php"> +strspn ("42 is the answer, what is the question ...", "1234567890"); + </programlisting> + <para> + 은 결과로 2를 반환한다. + </para> + </informalexample> + </para> + <simpara> + <function>strcspn</function>을 참고하라. + </simpara> + </refsect1> + </refentry> + <refentry id="function.strstr"> + <refnamediv> + <refname>strstr</refname> + <refpurpose>문자열의 처음 어커런스를 +찾는다</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strstr</function> + </funcdef> + <paramdef>string +<parameter>haystack</parameter> + </paramdef> + <paramdef>string <parameter>needle</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>needle</parameter>의 처음 +어커런스부터 끋까지의 + <parameter>haystack</parameter> 전부를 반환한다. + </para> + <para> + <parameter>needle</parameter> 이 발견되지 +않으면, 거짓을 반환한다. + </para> + <para> + 만약 <parameter>needle</parameter>이 문자열이 아니면, 이는 숫자로 +변환되고 + 문자의 순서값처럼 적용된다. + </para> + <para> + <note> + <para> + 이 함수는 대소문자를 구분하며, 대소문자의 구분이 필 요 +없을 때 + <function>stristr</function>을 사용하라. + </para> + </note> + </para> + <para> + <example> + <title> + <function>Strstr</function> 예</title> + <programlisting role="php"> +$email = '[EMAIL PROTECTED]'; +$domain = strstr ($email, '@'); +print $domain; // prints @designmultimedia.com + </programlisting> + </example> + </para> + <para> + <function>stristr</function>, + <function>strrchr</function>, <function>substr</function>, 그리고 + <function>ereg</function>. + </para> + </refsect1> + </refentry> + <refentry id="function.strtok"> + <refnamediv> + <refname>strtok</refname> + <refpurpose>문자열을 토큰화한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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>은 문자열을 토큰화 +하는데 사용된다. + 즉, "This is an example string"와 같은 문자열이 있으면, + 토큰으로 공백 문자를 사용하여 이 문자열을 가각의 +단어를 토큰화 할 수 있다. + <example> + <title> + <function>Strtok</function> 예</title> + <programlisting role="php"> +$string = "This is an example string"; +$tok = strtok ($string," "); +while ($tok) { + echo "Word=$tok<br>"; + $tok = strtok (" "); +} + </programlisting> + </example> + </para> + <para> + 오로지 처음 불리워진 strtok 이 문자열 인수를 사용한다. + 뒤에 나오는 각각의 strtok 호출을 사용함에 있어 토큰만이 +필요하며 + 이는 현재의 문자열 트랙을 유지하기 때문이다. + 다시 시작하거나 새로운 문자열을 토큰화 하고자 한다면, + 이를 초기화 하기 위해 단순히 문자열 인수와 함께 strtok 를 +호출하면 된다. + 다수의 토큰을 토큰 매개변수에 넣을 수도 있으며, + 문자열은 매개변수에 있는 문자 중 아무것 하나를 만나면, +토큰화 된다. + </para> + <para> + 생성된 토큰은 "0" 이 될 수도 있음을 유의하라. + 이는 조건식에서 거짓을 나타내는 값이기도 하다. + </para> + <para> + <function>split</function> 그리고 + <function>explode</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strtolower"> + <refnamediv> + <refname>strtolower</refname> + <refpurpose>문자열을 소문자로 만든다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtolower</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>string</parameter>의 모든 알파벳을 +소문자로 변환한 문자열을 반환한다. + </para> + <para> + '알파벳'이라 함은 현재 로케일에 의 해 정해진다. 이는 즉 +기본적으로 "C" 로케일에서 + umlaut-A (© 같은 문자는 바뀌지 않음을 의미한다. + </para> + <example> + <title> + <function>Strtolower</function> 예</title> + <programlisting role="php"> +$str = "Mary Had A Little Lamb and She LOVED It So"; +$str = strtolower($str); +print $str; # mary had a little lamb and she loved it so 를 출력한다. + </programlisting> + </example> + <para> + <function>strtoupper</function> + 그리고 <function>ucfirst</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strtoupper"> + <refnamediv> + <refname>strtoupper</refname> + <refpurpose>문자열을 대문자로 만든다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>strtoupper</function> + </funcdef> + <paramdef>string <parameter>string</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>string</parameter>의 모든 알파벳을 +대문자로 변환한 문자열을 반환한다. + </para> + <para> + '알파벳'이라 함은 현재 로케일에 의 해 정해진다. 이는 즉 +기본적으로 "C" 로케일에서 + umlaut-a(⧠ 같은 문자는 바뀌지 않음을 의미한다. + </para> + <example> + <title> + <function>Strtoupper</function> 예</title> + <programlisting role="php"> +$str = "Mary Had A Little Lamb and She LOVED It So"; +$str = strtoupper ($str); +print $str; # MARY HAD A LITTLE LAMB AND SHE LOVED IT SO 을 출력한다. + </programlisting> + </example> + <para> + <function>strtolower</function> + 그리고 <function>ucfirst</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.str-replace"> + <refnamediv> + <refname>str_replace</refname> + <refpurpose> + haystack 의 모든 needle을 str로 변환한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 <parameter>haystack</parameter>의 +<parameter>needle</parameter>을 + 주어진 <parameter>str</parameter>로 바꾼다. + (This function replaces all occurences of <parameter>needle</parameter> in +<parameter>haystack</parameter> + with the given <parameter>str</parameter>.) + 만약 복잡한 치환 룰이 필요하지 않다면, +<function>ereg_replace</function> 대신 + 이 함수를 사용하여도 된다. + </para> + <para> + <example> + <title> + <function>Str_replace</function> +예</title> + <programlisting role="php"> +$bodytag = str_replace ("%body%", "black", "<body text=%body%>"); + </programlisting> + </example> + </para> + <para> + 이 함수는 binary safe. + </para> + <note> + <para> + <function>Str_replace</function>는 PHP +3.0.6,에서 추가되었지만, + PHP 3.0.8 에 버그가 수정되었다. + </para> + </note> + <para> + <function>ereg_replace</function> 그리고 + <function>strtr</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.strtr"> + <refnamediv> + <refname>strtr</refname> + <refpurpose>특정 문자를 번역한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + 이 함수는 <parameter>str</parameter>에 대해 +<parameter>from</parameter>에 표함되는 각각의 문자를 + <parameter>to</parameter>에 있는 대응되는 문자로 번역하고 그 +결과를 반환한다. + </para> + <para> + <parameter>from</parameter>과 +<parameter>to</parameter>가 + 다른 길이일 때 둘 중 긴 문자열의 나머지 문자들은 +무시된다. + <example> + <title> + <function>Strtr</function> 예</title> + <programlisting role="php"> +$addr = strtr($addr, "妶", "aao"); + </programlisting> + </example> + </para> + <para> + <function>strtr</function>은 단지 두개의 +인자를 가질 수 도 있다. + 만약 두개의 인자만 가지고 호출된다면 새로운 방식으로 +동작한다.: + 이때 <parameter>from</parameter>은 소스에서 변환 될 + 문자열 -> 문자열 쌍을 갖는 배열이어야 한다. + <function>strtr</function>은 항상 처음에 가장 긴 번역 가능한 +매치를 찾고 + 그 후 이미 번역된 것은 다시 치환하려고 하지 않을 것이다. + </para> + <para> + 예: + <informalexample> + <programlisting role="php"> +$trans = array ("hello" => "hi", "hi" => "hello"); +echo strtr("hi all, I said hello", $trans) . "\n"; + </programlisting> + </informalexample> + This will show: "hello all, I said hi", + </para> + <note> + <simpara> + 두 인수를 이용하는 방법은 PHP 4.0 에서 추가되었다. + </simpara> + </note> + <para> + <function>ereg_replace</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.substr"> + <refnamediv> + <refname>substr</refname> + <refpurpose>문자열의 일부를 반환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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은 <parameter>start</parameter>와 <parameter>length</parameter> + 매개변수에 의해 지정된 <parameter>string</parameter> 문자열의 +일부를 반환한다. + </para> + <para> + 만약 <parameter>start</parameter>양수라면, 반환되는 문자열은 + 0부터 시작되는 <parameter>string</parameter>의 +<parameter>start</parameter>번째 위치에서 + 시작하는 문자열이 될 것이다. + 예를 들어 문자열 '<literal>abcdef</literal>'이 있다고 하자. + <literal>0</literal>의 위치에 있는 문자는 '<literal>a</literal>'가 +되고, + <literal>2</literal>의 위치에 있는 문자는 '<literal>c</literal>'가 +되는 식이다. + </para> + <para> + 예: + <informalexample> + <programlisting role="php"> +$rest = substr ("abcdef", 1); // "bcdef" 을 반환한다. +$rest = substr ("abcdef", 1, 3); // "bcd" 을 반환한다. + </programlisting> + </informalexample> + </para> + <para> + 만약 <parameter>start</parameter>가 음수라면, + 반환되는 문자열은 <parameter>string</parameter>의 끝에서부터 + <parameter>start</parameter>번째 부터 시작하는 문자열이 된다. + </para> + <para> + 예: + <informalexample> + <programlisting role="php"> +$rest = substr ("abcdef", -1); // "f" 를 반환 +$rest = substr ("abcdef", -2); // "ef" 를 반환 +$rest = substr ("abcdef", -3, 1); // "d" 를 반환 + </programlisting> + </informalexample> + </para> + <para> + 만약 <parameter>length</parameter>이 주어지고 양의 값이라면, + 반환되는 문자열은 <parameter>start</parameter>에서 시작해서 + <parameter>length</parameter>에서 끝나는 문자열이 될 것이다. + 만약 (시작이 문자열의 끝을 지나기 때문에) 문자열이 음의 +길이를 갖는 결과가 된다면, + 반환되는 문자열은 <parameter>start</parameter>의 문자 하나가 될 +것이다. + (역자주: 빈문자열이 출력된다.) + </para> + <para> + 만약 <parameter>length</parameter>이 음의 값이라면, + 스트링의 끝에서 부터 시작해서 <parameter>length</parameter>의 + 위치에 있는 문자가 반환되는 문자열의 끝이 되는 +문자열이 된다. + 만약 문자열이 음의 길이를 갖는 결과가 나온다면, + 반환되는 문자열은 <parameter>start</parameter>의 문자 하나가 될 +것이다. + (역자주: 빈문자열이 출력된다.) + </para> + <para> + 예: + <informalexample> + <programlisting role="php"> +$rest = substr ("abcdef", 1, -1); // "bcde"를 반환한다. + </programlisting> + </informalexample> + </para> + <para> + <function>strrchr</function> 그리고 + <function>ereg</function>를 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.substr-count"> + <refnamediv> + <refname>substr_count</refname> + <refpurpose>부분문자열의 수를 센다</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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>은 +<parameter>haystack</parameter> 문자열에 + 있는 <parameter>needle</parameter> 부분 문자열의 수를 반환한다. + </para> + <para> + <example> + <title> + <function>substr_count</function> +예</title> + <programlisting> +print substr_count("This is a test", "is"); // 2를 출력한다. + </programlisting> + </example> + </para> + </refsect1> + </refentry> + <refentry id="function.substr-replace"> + <refnamediv> + <refname>substr_replace</refname> + <refpurpose>문자열의 일부를 치환한다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> 는 +<parameter>string</parameter>의 + <parameter>start</parameter> 와 (선택적으로) +<parameter>length</parameter>로 + 정해진 구간에 해당하는 부분을 +<parameter>replacement</parameter>로 치환하고 + 그 결과를 반환한다. + </para> + <para> + <parameter>start</parameter>가 양수라면 +<parameter>string</parameter>의 + <parameter>start</parameter>번째 치환이 일어난다. + </para> + <para> + <parameter>start</parameter>가 음수라면, +<parameter>string</parameter>의 끝에서 부터 + <parameter>start</parameter>번째 문자까지의 문자열을 치환한다. + </para> + <para> + <parameter>length</parameter>이 양수라면, 이는 +치환 될 + <parameter>string</parameter>의 일부분의 길이를 나타낸다. + 만약 음수라면, <parameter>string</parameter>의 끝에서 부터의 + 문자의 수를 나타낸다. + 만약 주어지지 않는다면 기본 값으로 +strlen(<parameter>string</parameter>) + 즉, <parameter>string</parameter>의 끝에서 치환이 끝남을 +의미한다. + </para> + <para> + <example> + <title> + <function>Substr_replace</function> +예</title> + <programlisting role="php"> +<?php +$var = 'ABCDEFGH:/MNRPQR/'; +echo "Original: $var<hr>\n"; + +/* 다음 두가지 예는 $var의 모든 문자열을 'bob'으로 치환한다. */ +echo substr_replace ($var, 'bob', 0) . "<br>\n"; +echo substr_replace ($var, 'bob', 0, strlen ($var)) . "<br>\n"; + +/* $var의 첫부분에 'bob' 을 삽입한다. */ +echo substr_replace ($var, 'bob', 0, 0) . "<br>\n"; + +/* 다음 두 에는 $var 내의 'MNRPQR' 을 'bob'으로 치환한다. */ +echo substr_replace ($var, 'bob', 10, -1) . "<br>\n"; +echo substr_replace ($var, 'bob', -7, -1) . "<br>\n"; + +/* $var로 부터'MNRPQR' 을 지운다. */ +echo substr_replace ($var, '', 10, -1) . "<br>\n"; +?> + </programlisting> + </example> + </para> + <para> + <function>str_replace</function> 그리고 + <function>substr</function>을 참고하라. + </para> + <note> + <simpara> + <function>Substr_replace</function> 는 PHP +4.0에서 추가되었다. + </simpara> + </note> + </refsect1> + </refentry> + <refentry id="function.trim"> + <refnamediv> + <refname>trim</refname> + <refpurpose> + 문자열의 처음과 끝에 있는 공백을 제거한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>trim</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 이 함수는 문자열의 처음과 끝에 있는 공백문자를 +제거하고 이 문자열을 반환한다. + 공백문자라 함은 "\n", "\r", "\t", "\v", "\0", 그리고 공백을 +말한다. + </para> + <para> + <function>chop</function>, <function>rtrim</function> +그리고 + <function>ltrim</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.ucfirst"> + <refnamediv> + <refname>ucfirst</refname> + <refpurpose>문자열의 처음 글자를 대문자로 +만든다.</refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ucfirst</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + 만약 문자열 <parameter>str</parameter>의 처음 문자가 +알파벳이라면, 그 처음 글자를 대문자로 만든다. + </para> + <para> + '알파벳'은 현재 로케일에 의해 정의된다. + 예를들면 로케일 디폴트가 "C" 로케일로 되어 있을 경우 + umlaut-a(⧠ 같은 문자는 바뀌지 않는다. + <example> + <title> + <function>Ucfirst</function> +예</title> + <programlisting role="php"> +$text = 'mary had a little lamb and she loved it so.'; +$text = ucfirst ($text); // $text 는 Mary had a little lamb + // and she loved it so. 로 바뀐다. + </programlisting> + </example> + </para> + <para> + <function>strtoupper</function> 그리고 + <function>strtolower</function>을 참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.ucwords"> + <refnamediv> + <refname>ucwords</refname> + <refpurpose> + 문자열에 있는 각 단어의 처음 글자를 대문자로 바꾼다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>ucwords</function> + </funcdef> + <paramdef>string <parameter>str</parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str</parameter>의 각각의 단어의 +첫문자가 알파벳이라면 + 그 글자를 대문자로 바꾼다. + <example> + <title> + <function>ucwords</function> +예</title> + <programlisting role="php"> +$text = "mary had a little lamb and she loved it so."; +$text = ucwords($text); // $text 는 : Mary Had A Little + // Lamb And She Loved It So. 이 된다. + </programlisting> + </example> + <note> + <simpara> + 단어의 정의는 뒤에 화이트스페이스가 올 때 까지의 +문자를 말한다. + (화이트스페이스란 공백, 폼피드, 누라인, 케리지리턴, +수직탭, 수평탭 을 일컫는다.) + </simpara> + </note> + </para> + <para> + <function>strtoupper</function>, + <function>strtolower</function> 그리고 <function>ucfirst</function>을 +참고하라. + </para> + </refsect1> + </refentry> + <refentry id="function.wordwrap"> + <refnamediv> + <refname>wordwrap</refname> + <refpurpose> + 정지문자를 이용해 주어진 수 만큼의 문자를 래핑한다. + </refpurpose> + </refnamediv> + <refsect1> + <title>설명</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> + <paramdef>int + <parameter> + <optional>cut</optional> + </parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + <parameter>str</parameter>문자열을 +<parameter>width</parameter> + 매개변수의 지정된 길이만큼(선택적) 랩핑한다. + 줄은 <parameter>break</parameter> 매개변수(선택적)에 의해 +분리된다. + </para> + <para> + <function>wordwrap</function>은 자동적으로 +75컬럼에서 랩을 하며, 브레이크로는 '\n'(뉴라인)을 사용한다. + </para> + <para> + <parameter>cut</parameter>이 1로 지정되면, +문자열은 항상 지정된 길이로 랩핑되며, 주어진 넓이보다 더 긴 +단어가 있다면, + 그 단어는 나누어 진다.(두번째 예제를 보라) + (See second example). + <note> + <para> + <parameter>cut</parameter> +매개변수는 PHP 4.0.3 에서 추가되었다. + </para> + </note> + </para> + <para> + <example> + <title> + <function>wordwrap</function> +예</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> + 이 예는 다음을 출력한다.: + </para> + <para> + <informalexample> + <programlisting> +The quick brown fox +jumped over the lazy dog. + </programlisting> + </informalexample> + </para> + <para> + <example> + <title> + <function>wordwrap</function> +예</title> + <programlisting role="php"> +$text = "A very long woooooooooooord."; +$newtext = wordwrap( $text, 8, "\n", 1); + +echo "$newtext\n"; + </programlisting> + </example> + </para> + <para> + 이 예는 다음을 출력한다.: + </para> + <para> + <informalexample> + <programlisting> +A very +long +wooooooo +ooooord. + </programlisting> + </informalexample> + </para> + <para> + <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: +-->