2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-08-20 09:37:01 +00:00
|
|
|
<!-- $Revision: 1.13 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.142 -->
|
|
|
|
<refentry id="function.wordwrap">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>wordwrap</refname>
|
|
|
|
<refpurpose>
|
|
|
|
Wraps a string to a given number of characters using a string
|
2004-08-20 09:37:01 +00:00
|
|
|
break character
|
2002-04-15 00:12:54 +00:00
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<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>
|
2004-08-12 18:12:00 +00:00
|
|
|
<methodparam choice="opt"><type>bool</type><parameter>cut</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
Returns a string with <parameter>str</parameter> wrapped
|
2003-05-23 01:05:32 +00:00
|
|
|
at the column number specified by the optional
|
2002-04-15 00:12:54 +00:00
|
|
|
<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
|
2003-05-23 01:05:32 +00:00
|
|
|
75 and break using '<literal>\n</literal>' (newline) if
|
|
|
|
<parameter>width</parameter> or <parameter>break</parameter>
|
|
|
|
are not given.
|
2002-04-15 00:12:54 +00:00
|
|
|
</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 apart.
|
|
|
|
(See second example).
|
|
|
|
<note>
|
|
|
|
<para>
|
2003-03-09 00:06:57 +00:00
|
|
|
The optional <parameter>cut</parameter> parameter was added in PHP
|
|
|
|
4.0.3
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</para>
|
2003-05-23 01:08:44 +00:00
|
|
|
<example>
|
|
|
|
<title><function>wordwrap</function> example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-05-30 16:47:59 +00:00
|
|
|
<?php
|
2002-04-15 00:12:54 +00:00
|
|
|
$text = "The quick brown fox jumped over the lazy dog.";
|
2004-04-12 16:32:57 +00:00
|
|
|
$newtext = wordwrap($text, 20, "<br />\n");
|
2002-04-15 00:12:54 +00:00
|
|
|
|
2004-04-12 16:32:57 +00:00
|
|
|
echo $newtext;
|
2003-05-30 16:47:59 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2003-05-23 01:05:32 +00:00
|
|
|
</programlisting>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
This example would display:
|
|
|
|
</para>
|
2003-05-23 01:05:32 +00:00
|
|
|
<screen>
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2004-04-12 16:32:57 +00:00
|
|
|
The quick brown fox<br />
|
|
|
|
jumped over the lazy<br />
|
|
|
|
dog.
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2003-05-23 01:05:32 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
2003-05-23 01:08:44 +00:00
|
|
|
<example>
|
|
|
|
<title><function>wordwrap</function> example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-05-30 16:47:59 +00:00
|
|
|
<?php
|
2002-04-15 00:12:54 +00:00
|
|
|
$text = "A very long woooooooooooord.";
|
2003-06-16 10:44:37 +00:00
|
|
|
$newtext = wordwrap($text, 8, "\n", 1);
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
echo "$newtext\n";
|
2003-05-30 16:47:59 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
2003-05-23 01:08:44 +00:00
|
|
|
</programlisting>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
This example would display:
|
|
|
|
</para>
|
2003-05-23 01:05:32 +00:00
|
|
|
<screen>
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
2003-05-23 01:05:32 +00:00
|
|
|
A very
|
|
|
|
long
|
|
|
|
wooooooo
|
2002-04-15 00:12:54 +00:00
|
|
|
ooooord.
|
|
|
|
]]>
|
2003-05-23 01:08:44 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
2004-05-25 18:49:45 +00:00
|
|
|
See also <function>nl2br</function> and
|
|
|
|
<function>chunk_split</function>.
|
2002-04-15 00:12:54 +00:00
|
|
|
</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
|
|
|
|
-->
|