Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3812

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Join array elements with a string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.htmlspecialchars.html">htmlspecialchars</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.join.html">join</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.implode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">implode</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">implode</span> &mdash; <span class="dc-title">Join array elements with a string</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.implode-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>implode</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$glue</code></span>
   , <span class="methodparam"><span class="type">array</span> <code class="parameter">$pieces</code></span>
   )</div>

  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>implode</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$pieces</code></span>
   )</div>

  <p class="para rdfs-comment">
   Join array elements with a <em><code class="parameter">glue</code></em> string.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
     <span class="function"><strong>implode()</strong></span> can, for historical reasons, accept
    its parameters in either order. For consistency with
     <span class="function"><a href="function.explode.html" class="function">explode()</a></span>, however, it may be less confusing
    to use the documented order of arguments.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.implode-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">glue</code></em></span>
     <dd>

      <p class="para">
       Defaults to an empty string.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">pieces</code></em></span>
     <dd>

      <p class="para">
       The array of strings to implode.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.implode-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string containing a string representation of all the array
   elements in the same order, with the glue string between each element.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.implode-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>4.3.0</td>
       <td>
        The <em><code class="parameter">glue</code></em> parameter became optional.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.implode-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-4840">
    <p><strong>Example #1  <span class="function"><strong>implode()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$array&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'lastname'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'email'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phone'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$comma_separated&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">implode</span><span style="color: #007700">(</span><span style="color: #DD0000">","</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$array</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$comma_separated</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;lastname,email,phone<br /><br />//&nbsp;Empty&nbsp;string&nbsp;when&nbsp;using&nbsp;an&nbsp;empty&nbsp;array:<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">implode</span><span style="color: #007700">(</span><span style="color: #DD0000">'hello'</span><span style="color: #007700">,&nbsp;array()));&nbsp;</span><span style="color: #FF8000">//&nbsp;string(0)&nbsp;""<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>   
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.implode-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">This function is
binary-safe.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.implode-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.explode.html" class="function" rel="rdfs-seeAlso">explode()</a> - Split a string by string</span></li>
    <li class="member"> <span class="function"><a href="function.preg-split.html" class="function" rel="rdfs-seeAlso">preg_split()</a> - Split string by a regular expression</span></li>
    <li class="member"> <span class="function"><a href="function.http-build-query.html" class="function" rel="rdfs-seeAlso">http_build_query()</a> - Generate URL-encoded query string</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.htmlspecialchars.html">htmlspecialchars</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.join.html">join</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>