<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.wordwrap.php',
    1 => 'wordwrap',
    2 => 'Realiza el ajuste de l&iacute;nea de un string',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Funciones de strings',
  ),
  'prev' => 
  array (
    0 => 'function.vsprintf.php',
    1 => 'vsprintf',
  ),
  'next' => 
  array (
    0 => 'changelog.strings.php',
    1 => 'Registro de cambios',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/strings/functions/wordwrap.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.wordwrap" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">wordwrap</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.2, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">wordwrap</span> &mdash; <span class="dc-title">Realiza el ajuste de línea de un string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.wordwrap-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>wordwrap</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$width</code><span class="initializer"> = 75</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$break</code><span class="initializer"> = &quot;\n&quot;</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$cut_long_words</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Realiza el ajuste de línea de un string.
   Los strings se cortan después de un carácter de espacio (U+0020) a menos que <code class="parameter">cut_long_words</code>
   esté definido como <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.wordwrap-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       El string de entrada.
      </p>
     </dd>
    
    
     <dt><code class="parameter">width</code></dt>
     <dd>
      <p class="para">
       El número de caracteres a partir del cual el string será cortado.
      </p>
     </dd>
    
    
     <dt><code class="parameter">break</code></dt>
     <dd>
      <p class="para">
       La línea se rompe utilizando <code class="parameter">break</code>, este parámetro opcional.
       No debe ser un string vacío.
      </p>
     </dd>
    
    
     <dt><code class="parameter">cut_long_words</code></dt>
     <dd>
      <p class="para">
       Si el parámetro <code class="parameter">cut_long_words</code> vale <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, el ajuste de línea del
       string se realizará siempre al tamaño <code class="parameter">width</code> o antes.
       Si se tiene una palabra que es más larga que el tamaño de ajuste, será
       cortada en trozos: ver el segundo ejemplo. Cuando vale <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>,
       la función no cortará la palabra, incluso si el parámetro
       <code class="parameter">width</code> es más pequeño que el tamaño de la palabra.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.wordwrap-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Devuelve el string proporcionado cortado a la longitud especificada.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.wordwrap-errors">
  <h3 class="title">Errores/Excepciones</h3>
  <p class="simpara">
   Si <code class="parameter">break</code> es un string vacío, se lanza una <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.wordwrap-changelog">
  <h3 class="title">Historial de cambios</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versión</th>
      <th>Descripción</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Si <code class="parameter">break</code> es un string vacío,
       se lanza una <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span>;
       anteriormente, en este caso, se emitía un <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> y se devolvía <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.wordwrap-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo con <span class="function"><strong>wordwrap()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text </span><span style="color: #007700">= </span><span style="color: #DD0000">"Portez ce vieux whisky au juge blond qui fume."</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newtext </span><span style="color: #007700">= </span><span style="color: #0000BB">wordwrap</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">, </span><span style="color: #0000BB">20</span><span style="color: #007700">, </span><span style="color: #DD0000">"&lt;br /&gt;\n"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$newtext</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Portez ce vieux&lt;br /&gt;
whisky au juge&lt;br /&gt;
blond qui fume.</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Ejemplo #2 Ejemplo con <span class="function"><strong>wordwrap()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text </span><span style="color: #007700">= </span><span style="color: #DD0000">"Un mot très très loooooooooooooooooong."</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newtext </span><span style="color: #007700">= </span><span style="color: #0000BB">wordwrap</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$newtext</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Un mot
très
très
looooooo
oooooooo
ooong.</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-3">
    <p><strong>Ejemplo #3 Ejemplo con <span class="function"><strong>wordwrap()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$text </span><span style="color: #007700">= </span><span style="color: #DD0000">"A very long woooooooooooooooooord. and something"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$newtext </span><span style="color: #007700">= </span><span style="color: #0000BB">wordwrap</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">, </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$newtext</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">A very
long
woooooooooooooooooord.
and
something</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.wordwrap-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.nl2br.php" class="function" rel="rdfs-seeAlso">nl2br()</a> - Inserta un salto de l&iacute;nea HTML en cada nueva l&iacute;nea</span></li>
    <li><span class="function"><a href="function.chunk-split.php" class="function" rel="rdfs-seeAlso">chunk_split()</a> - Divide un string</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>