php-doc-en/reference/strings/functions/wordwrap.xml
Hannes Magnusson c030e2adf7 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@238160 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-20 22:25:43 +00:00

180 lines
4.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.17 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.wordwrap">
<refnamediv>
<refname>wordwrap</refname>
<refpurpose>Wraps a string to a given number of characters</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>wordwrap</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>width</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>break</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>cut</parameter></methodparam>
</methodsynopsis>
<para>
Wraps a string to a given number of characters using a string break
character.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>str</parameter></term>
<listitem>
<para>
The input string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>width</parameter></term>
<listitem>
<para>
The column width. Defaults to 75.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>break</parameter></term>
<listitem>
<para>
The line is broken using the optional
<parameter>break</parameter> parameter. Defaults to
'<literal>\n</literal>'.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>cut</parameter></term>
<listitem>
<para>
If the <parameter>cut</parameter> is set to &true;, 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 apart. (See second
example).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the given string wrapped at the specified column.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>4.0.3</entry>
<entry>
The optional <parameter>cut</parameter> parameter was added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>wordwrap</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");
echo $newtext;
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
The quick brown fox<br />
jumped over the lazy<br />
dog.
]]>
</screen>
</example>
<example>
<title><function>wordwrap</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$text = "A very long woooooooooooord.";
$newtext = wordwrap($text, 8, "\n", true);
echo "$newtext\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
A very
long
wooooooo
ooooord.
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>nl2br</function></member>
<member><function>chunk_split</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:"../../../../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
-->