Re: delete part of array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
>   (
>       [0] => grape
>       [1] => apple
>       [2] => 
>       [3] => orange
>       [4] => 
>       [5] => cherry
>   )
> 
> to:
> 
> [name] => Array
>   (
>       [0] => grape
>       [1] => apple
>       [2] => orange
>       [3] => cherry
>   )
-- 
Regards,
Matthew Fonda

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux