<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc'; $TOC = array(); $TOC_DEPRECATED = array(); $PARENTS = array(); include_once dirname(__FILE__) ."/toc/class.ds-vector.inc"; $setup = array ( 'home' => array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'de', ), 'this' => array ( 0 => 'ds-vector.map.php', 1 => 'Ds\\Vector::map', 2 => 'Returns the result of applying a callback to each value', ), 'up' => array ( 0 => 'class.ds-vector.php', 1 => 'Ds\\Vector', ), 'prev' => array ( 0 => 'ds-vector.last.php', 1 => 'Ds\\Vector::last', ), 'next' => array ( 0 => 'ds-vector.merge.php', 1 => 'Ds\\Vector::merge', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/ds/ds/vector/map.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?> <div id="ds-vector.map" class="refentry"> <div class="refnamediv"> <h1 class="refname">Ds\Vector::map</h1> <p class="verinfo">(PECL ds >= 1.0.0)</p><p class="refpurpose"><span class="refname">Ds\Vector::map</span> — <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">Beschreibung</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>Ds\Vector::map</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$callback</code></span>): <span class="type"><a href="class.ds-vector.php" class="type Ds\Vector">Ds\Vector</a></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">Parameter-Liste</h3> <dl> <dt><code class="parameter">callback</code></dt> <dd> <p class="para"> <div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">callback</span></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div> </p> <p class="para"> A <span class="type"><a href="language.types.callable.php" 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">Rückgabewerte</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">Hinweis</strong>: <p class="para"> The values of the current instance won't be affected. </p> </p></blockquote> </div> <div class="refsect1 examples" id="refsect1-ds-vector.map-examples"> <h3 class="title">Beispiele</h3> <div class="example" id="example-4304"> <p><strong>Beispiel #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"><?php<br />$vector </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Ds\Vector</span><span style="color: #007700">([</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </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">-></span><span style="color: #0000BB">map</span><span style="color: #007700">(function(</span><span style="color: #0000BB">$value</span><span style="color: #007700">) { return </span><span style="color: #0000BB">$value </span><span style="color: #007700">* </span><span style="color: #0000BB">2</span><span style="color: #007700">; }));<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">?></span></span></code></div> </div> <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:</p></div> <div class="example-contents screen"> <div class="examplescode"><pre class="examplescode">Ds\Vector Object ( [0] => 2 [1] => 4 [2] => 6 ) Ds\Vector Object ( [0] => 1 [1] => 2 [2] => 3 )</pre> </div> </div> </div> </div> </div><?php manual_footer($setup); ?>