1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-27 01:02:08 +01:00
Files
archived-doc-en/reference/strings/functions/ucwords.xml
Tim Starling 54ff7bf8e0 Updates for RFC: Locale-independent case conversion (#1934)
* Add a detailed description of what is meant by ASCII case conversion
  to strtolower() and strtoupper().
* Replace locale-related text on ucfirst(), lcfirst() and ucwords()
  with text about ASCII case conversion.
* Remove entity note.locale-single-byte since it was only used on
  ucwords().
* Add changelog entries to all the functions mentioned in the RFC.

Co-authored-by: George Peter Banyard <girgias@php.net>
2022-11-07 14:17:15 +00:00

173 lines
4.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.ucwords" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>ucwords</refname>
<refpurpose>Uppercase the first character of each word in a string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>ucwords</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>separators</parameter><initializer>" \t\r\n\f\v"</initializer></methodparam>
</methodsynopsis>
<para>
Returns a string with the first character of each word in
<parameter>string</parameter> capitalized, if that character is an ASCII
character between <literal>"a"</literal> (0x61) and <literal>"z"</literal>
(0x7a).
</para>
<para>
For this function, a word is a string of characters that are not listed in
the <parameter>separators</parameter> parameter. By default, these are:
space, horizontal tab, carriage return, newline, form-feed and vertical tab.
</para>
<para>
To do a similar conversion on multibyte strings, use
<function>mb_convert_case</function> with the <constant>MB_CASE_TITLE</constant>
mode.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
The input string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>separators</parameter></term>
<listitem>
<para>
The optional <parameter>separators</parameter> contains the word separator characters.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the modified string.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&strings.changelog.ascii-case-conversion;
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>ucwords</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = 'hello world!';
$foo = ucwords($foo); // Hello World!
$bar = 'HELLO WORLD!';
$bar = ucwords($bar); // HELLO WORLD!
$bar = ucwords(strtolower($bar)); // Hello World!
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><function>ucwords</function> example with custom delimiter</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = 'hello|world!';
$bar = ucwords($foo); // Hello|world!
$baz = ucwords($foo, "|"); // Hello|World!
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><function>ucwords</function> example with additional delimiters</title>
<programlisting role="php">
<![CDATA[
<?php
$foo = "mike o'hara";
$bar = ucwords($foo); // Mike O'hara
$baz = ucwords($foo, " \t\r\n\f\v'"); // Mike O'Hara
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&note.bin-safe;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>strtoupper</function></member>
<member><function>strtolower</function></member>
<member><function>ucfirst</function></member>
<member><function>mb_convert_case</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->