aktuelle.kurse/old_m133/4_Modulinhalte_und_Uebungen/00-Anwendungen-Beispiele-Uebungen/PHP_Referenz/funktionsreferenz/array_funktionen/array_splice.html

290 lines
13 KiB
HTML
Raw Normal View History

2022-02-23 22:44:33 +01:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>array_splice</title>
<link rel="stylesheet" type="text/css" href="../../src/self.css">
<meta name="description" content="&Auml;ndert ein Array in beliebiger Form">
<meta name="keywords" content="SELFPHP, PHP, Array-Funktionen, array_splice">
<meta name="author" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Contributer" content="Matthias Hupp, m.hupp@selfphp3.de">
<meta name="DC.Publisher" content="Damir Enseleit, mail@selfphp.info">
<meta name="DC.Date" content="2001-08-06T12:18+01:00">
<meta name="DC.Identifier" content="http://www.selfphp3.de/funktionsreferenz/array_funktionen/array_splice.html">
<meta name="DC.Language" content="de">
<meta name="DC.Rights" content="../../editorial/index.html">
<meta name="SELF.Firstdate" content="2001-08-06T12:18+01:00">
<meta name="SELF.Version" content="1">
<meta name="SELF.Pagetype" content="Information">
<meta name="SELF.Path" content="SELFPHP == ../../index.php // Funktionsreferenz == ../index.php // Array-Funktionen == index.html">
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#AA5522" vlink="#772200" alink="#000000">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="top"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a> <a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"> <a href="index.html"><b>Array-Funktionen</b></a></td>
</tr>
</table>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#EEEEEE" class="doc" width="110"><img src="../../src/logo.gif" width="106" height="109" border="0" alt="SEL.html"></td>
<td bgcolor="#EEEEEE" class="doc" valign="bottom" width="100%">
<h2>array_splice</h2></td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" valign="top" align="center"> <img src="../../src/dokx.gif" width="30" height="20" vspace="6" border="0" alt="Informationsseite">
</td>
<td bgcolor="#FFFFFF" valign="top" nowrap>
<p> <img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#befehl"><b>Befehl</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#version"><b>Version</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beschreibung"><b>Beschreibung</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel1"><b>Beispiel1</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe1"><b>Ausgabe1</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel2"><b>Beispiel2</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe2"><b>Ausgabe2</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel3"><b>Beispiel3</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe3"><b>Ausgabe3</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#beispiel4"><b>Beispiel4</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe4"><b>Ausgabe4</b></a><br>
</p>
</td>
</tr>
<tr>
<td colspan=3 bgcolor="#EEEEEE" class="doc"><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;</td>
</tr>
</table>
<h2 class="Sh2"><a class="an" name="befehl">Befehl</a></h2>
<table width="100%" cellpadding=10><tr>
<td class="xmpcode" bgcolor="#E4EEFF">array <b>array_splice</b>(array input,
int offset [, int length [, array replacement]])</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="version">Version</a></h2>
<table width="100%" cellpadding=10 height="32">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="20">
<p>PHP 4 &gt;= 4.0b1</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beschreibung">Beschreibung</a></h2>
<table width="100%" cellpadding=10 height="141">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>Die Funktion array_splice() ersetzt oder entfernt einen Teilbereich aus
einem<br>
Array (input). Der Teilbereich ist definiert durch den Index des ersten
Elements<br>
(offset) und die Anzahl der Elemente (length, Default-Wert sind alle Elemente
bis<br>
zum Ende des Arrays). Enth&auml;lt der Parameter replacement ein Array,
f&uuml;gt die<br>
Funktion dieses Array an der Stelle ein, wo sie die gew&uuml;nschten Elemente<br>
entfernt hat.<br>
Das so entstandene Array wird als Funktionsergebnis zur&uuml;ckgegeben.<br>
Der Parameter offset gibt den Index des Startelements an. Ist offset positiv,
so<br>
wird vom Anfang des Arrays gez&auml;hlt. Ist offset hingegen negativ,
so wird vom<br>
Ende des Arrays gez&auml;hlt. <br>
</p>
<p>Siehe auch:</p>
<ul>
<li><a href="array_slice.html">array_slice()</a></li>
</ul>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel1">Beispiel1</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br>$array1 = array(&quot;php&quot;,&quot;asp&quot;,&quot;perl&quot;,&quot;c&quot;,&quot;test&quot;);<br>$array2 = array_splice($array1, 1, -2);
for($x=0;$x&lt;count($array1);$x++){ <br> echo $array1[$x] . &quot;&lt;br&gt;&quot;;<br>}<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe1">Ausgabe1</a></h2>
<table width="100%" cellpadding=10 height="42">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>php<br>
c<br>
test</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel2">Beispiel2</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br>$array1 = array(&quot;php&quot;,&quot;asp&quot;,&quot;perl&quot;,&quot;c&quot;,&quot;test&quot;);<br>$array2 = array_splice($array1, 3);
for($x=0;$x&lt;count($array1);$x++){ <br> echo $array1[$x] . &quot;&lt;br&gt;&quot;;<br>}<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe2">Ausgabe2</a></h2>
<table width="100%" cellpadding=10 height="42">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>php<br>
asp<br>
perl</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel3">Beispiel3</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br>$array1 = array(&quot;php&quot;,&quot;asp&quot;,&quot;perl&quot;,&quot;c&quot;,&quot;test&quot;);<br>$array2 = array_splice($array1, 2, count($array1), &quot;test&quot;);
for($x=0;$x&lt;count($array1);$x++){ <br> echo $array1[$x] . &quot;&lt;br&gt;&quot;;<br>}<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe3">Ausgabe3</a></h2>
<table width="100%" cellpadding=10 height="42">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>php<br>
asp<br>
test</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="beispiel4">Beispiel4</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
<pre>&lt;?PHP<br>$array1 = array(&quot;php&quot;,&quot;asp&quot;,&quot;perl&quot;,&quot;c&quot;,&quot;test&quot;);<br>$array2 = array_splice($array1, -2, 2, array(&quot;uhr&quot;, &quot;zeit&quot;));
for($x=0;$x&lt;count($array1);$x++){ <br> echo $array1[$x] . &quot;&lt;br&gt;&quot;;<br>}<br>?&gt;</pre>
</td>
</tr></table>
<p>&nbsp;</p>
<table bgcolor="#EEEEEE" class="doc" width="100%"><tr><td>
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a><a href="#bottom"><img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten"></a>&#160;
</td></tr></table>
<h2 class="Sh2"><a class="an" name="ausgabe4">Ausgabe4</a></h2>
<table width="100%" cellpadding=10 height="42">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
<p>php<br>
asp<br>
perl<br>
uhr<br>
zeit</p>
</td>
</tr></table>
<p>&nbsp;</p>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">
<a href="#top"><img src="../../src/up.gif" width="14" height="10" border="0" alt="nach oben"></a>
</td></tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">weiter:<a href="array_sum.html"><img src="../../src/next.gif" width="10" height="10" border="0" hspace="10" alt="weiter"></a></td>
<td bgcolor="#FFFFFF"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="array_sum.html"><b>array_sum</b></a> </td>
</tr>
<tr>
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">zur&uuml;ck:<a href="array_slice.html"><img src="../../src/prev.gif" width="10" height="10" border="0" hspace="10" alt="zur&uuml;ck"></a></td>
<td bgcolor="#FFFFFF" width="100%"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
<a href="array_slice.html"><b>array_slice</b></a> </td>
</tr>
<tr><td colspan=2 bgcolor="#EEEEEE" class="doc">&#160;</td></tr>
</table><table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
<td bgcolor="#FFEEDD" class="nav"><a class="an" name="bottom"><img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von"></a>
<a href="../../index.html"><b>SELFPHP</b></a>/<a href="../../navigation/index.html">Navigationshilfen</a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="../index.html"><b>Funktionsreferenz</b></a> <img src="../../src/refkap.gif" width="16" height="13" border="0" alt="Teil von">
<a href="index.html"><b>Array-Funktionen</b></a></td>
</tr>
</table>
<p><a class="an" name="bottom">&copy; 2001, 2002, 2003</A> <img src="../../src/mail.gif" width="15" height="10" border="0" alt="E-Mail">&nbsp;<a href="mailto:mail@selfphp.info">Damir Enseleit, mail@selfphp.info</a></p>
</body>
</html>