Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 1996

php-manual-en-7.2.11-1.mga7.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>Returns the result of applying a callback to each value</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ds-vector.last.html">Ds\Vector::last</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ds-vector.merge.html">Ds\Vector::merge</a></div>
 <div class="up"><a href="class.ds-vector.html">Vector</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="ds-vector.map" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Ds\Vector::map</h1>
  <p class="verinfo">(PECL ds &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">Ds\Vector::map</span> &mdash; <span class="dc-title">Returns the result of applying a callback to each value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-ds-vector.map-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><span class="type Ds\Vector">Ds\Vector</span></span> <span class="methodname"><strong>Ds\Vector::map</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>
   )</div>

  <p class="para rdfs-comment">
    Returns the result of applying a <code class="parameter">callback</code> function to
    each value in the vector.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-ds-vector.map-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt>
<code class="parameter">callback</code></dt>


    <dd>

        <p class="para">
            <div class="methodsynopsis dc-description">
                <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> 
                <span class="methodname"><span class="replaceable">callback</span></span>
                 ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>
              )</div>

         </p>
         <p class="para">
            A <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> to apply to each value in the vector.
         </p>

         <p class="para">
            The callable should return what the new value will be in the new vector.
        </p>
    </dd>


   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-ds-vector.map-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
    The result of applying a <code class="parameter">callback</code> to each value in
    the vector.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
        The values of the current instance won&#039;t be affected.
    </p>
  </p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-ds-vector.map-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-5187">
   <p><strong>Example #1 <span class="function"><strong>Ds\Vector::map()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$vector&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;\</span><span style="color: #0000BB">Ds</span><span style="color: #007700">\</span><span style="color: #0000BB">Vector</span><span style="color: #007700">([</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$vector</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">map</span><span style="color: #007700">(function(</span><span style="color: #0000BB">$value</span><span style="color: #007700">)&nbsp;{&nbsp;return&nbsp;</span><span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">*&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">;&nbsp;}));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$vector</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
Ds\Vector Object
(
    [0] =&gt; 2
    [1] =&gt; 4
    [2] =&gt; 6
)
Ds\Vector Object
(
    [0] =&gt; 1
    [1] =&gt; 2
    [2] =&gt; 3
)
</pre></div>
   </div>
  </div>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="ds-vector.last.html">Ds\Vector::last</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ds-vector.merge.html">Ds\Vector::merge</a></div>
 <div class="up"><a href="class.ds-vector.html">Vector</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>