mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-25 05:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@336762 c90b9560-bf6c-de11-be94-00142212c4b1
179 lines
4.2 KiB
XML
179 lines
4.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<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><initializer>75</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>break</parameter><initializer>"\n"</initializer></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>cut</parameter><initializer>false</initializer></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 number of characters at which the string will be wrapped.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>break</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The line is broken using the optional
|
|
<parameter>break</parameter> parameter.
|
|
</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 or before the specified <parameter>width</parameter>. So if you have
|
|
a word that is larger than the given width, it is broken apart.
|
|
(See second example). When &false; the function does not split the word
|
|
even if the <parameter>width</parameter> is smaller than the word width.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns the given string wrapped at the specified length.
|
|
</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>
|
|
<example>
|
|
<title><function>wordwrap</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$text = "A very long woooooooooooooooooord. and something";
|
|
$newtext = wordwrap($text, 8, "\n", false);
|
|
|
|
echo "$newtext\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
A very
|
|
long
|
|
woooooooooooooooooord.
|
|
and
|
|
something
|
|
]]>
|
|
</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:"~/.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
|
|
-->
|