aktuelle.kurse/oldies/m133/4_Modulinhalte_und_Uebungen/00-Anwendungen-Beispiele-Uebungen/PHP_Referenz/funktionsreferenz/regulaere_ausdruecke_posix/split.html

183 lines
9.6 KiB
HTML
Raw Normal View History

2022-02-24 09:37:43 +01:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
2022-03-17 11:19:26 +01:00
<title>split</title>
2022-02-24 09:37:43 +01:00
<link rel="stylesheet" type="text/css" href="../../src/self.css">
2022-03-17 11:19:26 +01:00
<meta name="description" content="Zerlegt eine Zeichenkette anhand eines regul&auml;ren Ausdrucks in ein Array">
<meta name="keywords" content="SELFPHP, PHP, Regul&auml;re Ausdr&uuml;cke (POSIX), split">
2022-02-24 09:37:43 +01:00
<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-21T12:18+01:00">
2022-03-17 11:19:26 +01:00
<meta name="DC.Identifier" content="http://www.selfphp3.de/funktionsreferenz/regulaere_ausdruecke_posix/split.html">
2022-02-24 09:37:43 +01:00
<meta name="DC.Language" content="de">
<meta name="DC.Rights" content="../../editorial/index.html">
<meta name="SELF.Firstdate" content="2001-08-21T12:18+01:00">
<meta name="SELF.Version" content="1">
<meta name="SELF.Pagetype" content="Information">
2022-03-17 11:19:26 +01:00
<meta name="SELF.Path" content="SELFPHP == ../../index.php // Funktionsreferenz == ../index.php // Regul&auml;re Ausdr&uuml;cke (POSIX) == index.html">
2022-02-24 09:37:43 +01:00
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#AA5522" vlink="#772200" alink="#000000">
<table cellpadding="4" cellspacing="0" border="0" width="100%">
<tr>
2022-03-17 11:19:26 +01:00
<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>Regul&auml;re Ausdr&uuml;cke (POSIX)</b></a></td>
2022-02-24 09:37:43 +01:00
</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>
2022-03-17 11:19:26 +01:00
<td bgcolor="#EEEEEE" class="doc" valign="bottom" width="100%">
<h2>split</h2>
2022-02-24 09:37:43 +01:00
<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="#beispiel"><b>Beispiel</b></a><br>
<img src="../../src/down.gif" width="14" height="10" border="0" alt="nach unten">&nbsp;<a href="#ausgabe"><b>Ausgabe</b></a><br>
</p>
</td>
</tr><tr><td colspan=2 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>
2022-03-17 11:19:26 +01:00
<td class="xmpcode" bgcolor="#E4EEFF">array <b>split</b>(string Suchmuster,
string Zeichenkette [, int Beschr&auml;nkung])</td>
2022-02-24 09:37:43 +01:00
</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">
2022-03-17 11:19:26 +01:00
<p>PHP 3, PHP 4 &gt;= 4.0b1</p>
2022-02-24 09:37:43 +01:00
</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>
2022-03-17 11:19:26 +01:00
<table width="100%" cellpadding=10 height="370">
2022-02-24 09:37:43 +01:00
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
2022-03-17 11:19:26 +01:00
<p>Mit split() kann man eine Zeichenkette (Zeichenkette) anhand eines regul&auml;ren<br>
Ausdrucks in ein Array zerlegen lassen. Dabei wird der regul&auml;re Ausdruck<br>
innerhalb des Suchmusters (Suchmuster) bestimmt und auf die Zeichenkette<br>
angewendet. Bei dem Suchmuster wird zwischen Gro&szlig;- und Kleinschreibung<br>
unterschieden. Die Zeichenkette wird nach jedem Suchtreffer geteilt, es
sei denn,<br>
dass Sie eine maximale Anzahl (Beschr&auml;nkung) f&uuml;r die Zerlegung
angegeben<br>
haben. Sind mehr Suchtreffer vorhanden, als in Beschr&auml;nkung angegeben,
so wird<br>
der Rest der Zeichenkette in dem letzten Array-Element abgelegt.<br>
Es ist darauf zu achten, dass wie auch bei &quot;normalen&quot; regul&auml;ren
Ausdr&uuml;cken<br>
gewisse Zeichen, die eine besondere Bedeutung haben, gesch&uuml;tzt werden
m&uuml;ssen.<br>
Weiterhin sollten Sie diese Funktion nur nutzen, wenn Sie auch wirklich
regul&auml;re<br>
Ausdr&uuml;cke brauchen, da diese Funktion die Engine f&uuml;r regul&auml;re
Ausdr&uuml;cke<br>
ben&ouml;tigt; eine schnellere Alternative ohne regul&auml;re Ausdr&uuml;cke
ist die Funktion<br>
explode().</p>
2022-02-24 09:37:43 +01:00
<p>Siehe auch:</p>
<ul>
2022-03-17 11:19:26 +01:00
<li><a href="spliti.html">spliti()</a></li>
<li><a href="../string_funktionen/explode.html">explode()</a></li>
<li><a href="../string_funktionen/implode.html">implode()</a></li>
2022-02-24 09:37:43 +01:00
</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="beispiel">Beispiel</a></h2>
<table width="100%" cellpadding=10 height="66">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF">
2022-03-17 11:19:26 +01:00
<pre>&lt;?PHP<br>$datei = &quot;image.jpg&quot;; <br>$endung = split(&quot;[.]&quot;,$datei); <br>echo &quot;Es handelt sich um eine $endung[1] -Datei&quot;;<br>echo &quot;&lt;br&gt;&quot;;<br>$var = &quot;Nehmen Sie hier besser explode()&quot;;<br>$array = split(&quot; &quot;,$var,3); <br>echo &quot;1: $array[0] 2: $array[1] 3: $array[2]&quot;;<br>echo &quot;&lt;br&gt;&quot;;<br>$datum = &quot;29.07.2001&quot;; <br>$array_1 = split (&quot;[./-]&quot;, $datum);<br>echo &quot;Tag: $array_1[0] Monat: $array_1[1] Jahr: $array_1[2]&quot;; <br>?&gt;</pre>
2022-02-24 09:37:43 +01:00
<p></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="ausgabe">Ausgabe</a></h2>
<table width="100%" cellpadding=10 height="45">
<tr>
<td class="xmpcode" bgcolor="#E4EEFF" height="57">
2022-03-17 11:19:26 +01:00
<p>Es handelt sich um eine jpg -Datei<br>
1: Nehmen 2: Sie 3: hier besser explode()<br>
Tag: 29 Monat: 07 Jahr: 2001</p>
<p></p>
</td>
2022-02-24 09:37:43 +01:00
</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>
2022-03-17 11:19:26 +01:00
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">weiter:<a href="spliti.html"><img src="../../src/next.gif" width="10" height="10" border="0" hspace="10" alt="weiter"></a></td>
2022-02-24 09:37:43 +01:00
<td bgcolor="#FFFFFF"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
2022-03-17 11:19:26 +01:00
<a href="spliti.html"><b>spliti</b></a> </td>
2022-02-24 09:37:43 +01:00
</tr>
<tr>
2022-03-17 11:19:26 +01:00
<td bgcolor="#EEEEEE" class="doc" align="right" width="110">zur&uuml;ck:<a href="eregi_replace.html"><img src="../../src/prev.gif" width="10" height="10" border="0" hspace="10" alt="zur&uuml;ck"></a></td>
2022-02-24 09:37:43 +01:00
<td bgcolor="#FFFFFF" width="100%"><img src="../../src/dok.gif" width="15" height="10" border="0" alt="Seite">
2022-03-17 11:19:26 +01:00
<a href="eregi_replace.html"><b>eregi_replace</b></a> </td>
2022-02-24 09:37:43 +01:00
</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">
2022-03-17 11:19:26 +01:00
<a href="index.html"><b>Regul&auml;re Ausdr&uuml;cke (POSIX)</b></a></td>
2022-02-24 09:37:43 +01:00
</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>