note 53304 deleted from language.types.array by nlopess
| From: | nlopess@php.net | Date: | Fri, 10 Jun 2005 08:44:23 +0000 |
| Subject: | note 53304 deleted from language.types.array by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-90211@lists.php.net to get a copy of this message | ||
Note Submitter: philipp_burch at gmx dot ch
----
// Nun löschen wir alle Elemente, lassen das Array selbst
// aber intakt:
foreach ($array as $i => $wert) {
unset($array[$i]);
}
Why?? Why doesn't it work like:
foreach ($array as $i) {
unset($array[$i]);
}
// Nun löschen wir alle Elemente, lassen das Array selbst
// aber intakt:
foreach ($array as $i => $wert) {
unset($array[$i]);
}
Why?? Why doesn't it work like:
foreach ($array as $i) {
unset($array[$i]);
}
That's because $i is the /value/ of the Element. To unset an Element you need the /key/.
greetz Phip