Reply to Re: [PHP] delete part of array

Your name:

Reply:


Posted by M. Sokolewicz on 10/04/80 11:06

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 :)

Another easy way would be:
foreach($array as $key=>$val) {
if($val === '') {
unset($array[$key]);
}
}

hope it helps
- Tul
Matthew Fonda wrote:
> 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
>> )

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация