Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8465
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: unset multidimensional array element |
| Date | 2013-02-23 20:34 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <kgbqlp$knu$1@dont-email.me> (permalink) |
| References | <1de87c2e-dd81-475a-8516-85c0885dca9a@p5g2000yqj.googlegroups.com> <kgbpm4$hcg$1@dont-email.me> <a9d6534c-33b4-4d64-802e-9f40ff7860c6@l13g2000yqe.googlegroups.com> <kgbpt1$hcg$2@dont-email.me> <c62e82c1-2d97-42d5-9b6a-bc1c8096c553@5g2000yqz.googlegroups.com> |
On 2/23/2013 8:24 PM, cate wrote: > On Feb 23, 7:21 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> On 2/23/2013 8:19 PM, cate wrote: >> >> >> >> >> >> >> >> >> >>> On Feb 23, 7:17 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: >>>> On 2/23/2013 7:18 PM, cate wrote: >> >>>>> Is this correct? >> >>>>> I remove an element from a multidee array. Numeric Indexing then >>>>> fails because the it's no longer 0, 1, 2 but instead 0, 2 after the >>>>> unset. It seems the a numeric index has graduated to a key. (I >>>>> think I read that's the way php works) >> >>>>> Do I have to repack this to get sequential indexing to work or is >>>>> there a php way to remove elements and maintain a "numeric" indexs? >> >>>>> I suppose I could make it a rule to use the construct foreach, but I >>>>> do so love for(;;). >> >>>>> Thank you in advance. >> >>>>> array ( >>>>> array (1, 2, 3), >>>>> array (4, 5, 6), >>>>> array (7, 8, 9) >>>>> ) >> >>>> All arrays in PHP are associative (hashes). If you remove an element, >>>> that key no longer exists. >> >>>> You can renumber the array, or you can use operators like foreach(), >>>> current(), next(), etc. and not worry about the keys. >> >>>> Very seldom do I need to care about the array indexes being in a >>>> specific order. >> >>> I don't think there is any alternative in php. Thank you. >> >> As I said - *in PHP* I very seldom need to care about the array indexes >> being in a specific order. There are many ways of doing things with >> arrays - and you don't even need a numeric index. >> > > Never an need for order (mumeric) is quite a statement. :-) > First of all, I said "VERY SELDOM" - not never. There are exceptions. It's all about knowing the language and using the appropriate features. It works quite well. P.S. Please learn to trim signatures. They shouldn't be copied. Thanks. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
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