Re: [PHP] delete part of array

2005-01-13 Thread Leif Gregory
Hello Jochem, Thursday, January 13, 2005, 10:55:35 AM, you wrote: J> heh but who says I'm not a bar steward ;-) I'll take a beer then! I need one after today. J> sorry if it came accross a little harsh, but I stand by the point J> that the onus is on the person asking the question to give an J>

Re: [PHP] delete part of array

2005-01-13 Thread John Nichel
Ford, Mike wrote: Without actually running it (I'm too lazy!), I'm pretty sure this won't work correctly -- the count($array) is being recalculated each time round the loop, so each time you do an unset() it will reduce by one, resulting in the last few elements never being checked. Not too much

Re: [PHP] delete part of array

2005-01-13 Thread Jochem Maas
crap - hit 'reply' by mistake. --- Leif Gregory wrote: > Hello Jochem, > > Wednesday, January 12, 2005, 8:08:09 PM, you wrote: > JM> read the manual entry first (see below) - and understand what the > JM> function actually does - never just assume because its giving you > JM> the result you want no

RE: [PHP] delete part of array

2005-01-13 Thread Ford, Mike
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 13 January 2005 05:28, Matthew Fonda wrote: > use the unset() function. > > for ($i = 0; $i < count($array); $i++) { > if (empty($array[$i]) { > unset($array

Re: [PHP] delete part of array

2005-01-13 Thread Sebastian
coder would go for help FIRST, but it doesn't always solve a problem thats why there is a thing called MAILING LIST. :) cheers. - Original Message - From: "Leif Gregory" <[EMAIL PROTECTED]> To: Sent: Thursday, January 13, 2005 7:39 AM Subject: Re: [PHP] delete pa

Re: [PHP] delete part of array

2005-01-13 Thread M. Sokolewicz
that only works for numerical indices. However, if you're sure that neither null values, nor false values are supposed to be present in the array, (that means, they MIGHT be, but should be removed anyway; or just not be there at all,) then you could try array_filter with no callback-argument :)

Re: [PHP] delete part of array

2005-01-13 Thread Matthew Fonda
use the unset() function. for ($i = 0; $i < count($array); $i++) { if (empty($array[$i]) { unset($array[$i]); } } On Wed, 2005-01-12 at 16:22, Sebastian wrote: > how do i delete keys from an array if it has no values? > eg, this: > > [name] => Array > ( >

Re: [PHP] delete part of array

2005-01-13 Thread Leif Gregory
Hello Jochem, Wednesday, January 12, 2005, 8:08:09 PM, you wrote: JM> read the manual entry first (see below) - and understand what the JM> function actually does - never just assume because its giving you JM> the result you want now that it will always work the way you JM> expect. Don't be a 'ta

Re: [PHP] delete part of array

2005-01-12 Thread Jochem Maas
Leif Gregory wrote: Hello Sebastian, Wednesday, January 12, 2005, 5:22:20 PM, you wrote: S> how do i delete keys from an array if it has no values? S> eg, this: array_merge($name); Try it that way first. If not, read the manual entry first (see below) - and understand what the function actually do

Re: [PHP] delete part of array

2005-01-12 Thread Jochem Maas
Sebastian wrote: how do i delete keys from an array if it has no values? eg, this: what does the value have to do with it??? other than that you want to remove items where the value is 'empty'. also 'no value' is vague, do you mean an empty string or do you mean NULL? --- try the array_values() f

Re: [PHP] delete part of array

2005-01-12 Thread Leif Gregory
Hello Sebastian, Wednesday, January 12, 2005, 5:22:20 PM, you wrote: S> how do i delete keys from an array if it has no values? S> eg, this: array_merge($name); Try it that way first. If not, $name = array_merge($name); But I think I remember the first way working for me. Cheers, Leif Gre

Re: [PHP] delete part of array

2005-01-12 Thread Tatang Widyanto
Sebastian wrote: how do i delete keys from an array if it has no values? eg, this: [name] => Array ( [0] => grape [1] => apple [2] => [3] => orange [4] => [5] => cherry ) to: [name] => Array ( [0] => grape [1] => apple [2] => orange