Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8469
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
| Newsgroups | comp.lang.php |
| Subject | Re: unset multidimensional array element |
| Date | Sun, 24 Feb 2013 17:25:44 +0100 |
| Lines | 51 |
| Message-ID | <aout88Ffoa0U1@mid.uni-berlin.de> (permalink) |
| References | <1de87c2e-dd81-475a-8516-85c0885dca9a@p5g2000yqj.googlegroups.com> <aoujigFdhp1U1@mid.uni-berlin.de> <4683f6ee-6169-46f8-9e21-0ec94f5c5d1f@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de giszAubwk+jyBbNUUp8SeAHsJy5kB7vPwPXCwq80M2qGH8bDZYotSM/2BVDszSuDI= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 |
| In-Reply-To | <4683f6ee-6169-46f8-9e21-0ec94f5c5d1f@googlegroups.com> |
| Xref | csiph.com comp.lang.php:8469 |
Show key headers only | View raw
Am 24.02.2013 16:36, schrieb catebekensail@yahoo.com:
>
>> This is the behaviour PHP programmers IMO like. Imagine you have a unique database
>>
>> key as index, I would not like it to be renumbered after deletion of one entry.
>>
>>
>>
>> /Str.
>
> Me neither ... :-)
>
> $a = array(1,2,3,4,5,9,8,7,6);
> unset($a[4]);
> print_r($a);
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[5] => 9
[6] => 8
[7] => 7
[8] => 6
)
> $ar = array_reverse($a);
> print_r($ar);
But:
$a = array(1=>'one',2=>'two',3=>'three',4=>'four');
unset($a[2]);
print_r($a);
Array
(
[1] => one
[3] => three
[4] => four
)
It must be difficult to understand for the beginner, but in fact "it just works" if
you set the index.
I counted 47 array functions with "array" in the name, and about the same number with
other names (http://php.net/manual/en/function.array.php), most of them I find fairly
unusable.
/Str.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 16:18 -0800
Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:17 -0500
Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:19 -0800
Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:21 -0500
Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:24 -0800
Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-23 20:34 -0500
Re: unset multidimensional array element cate <catebekensail@yahoo.com> - 2013-02-23 17:40 -0800
Re: unset multidimensional array element "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-24 14:40 +0100
Re: unset multidimensional array element catebekensail@yahoo.com - 2013-02-24 07:36 -0800
Re: unset multidimensional array element "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-02-24 17:25 +0100
Re: unset multidimensional array element Captain Paralytic <paul_lautman@yahoo.com> - 2013-02-25 04:01 -0800
Re: unset multidimensional array element Jerry Stuckle <jstucklex@attglobal.net> - 2013-02-25 11:13 -0500
csiph-web