This request seems pretty valid...
Say.... um you had an array that you delete from and create elements
frequently.. amost like a db table... and you wanted to clean this
periocally.. in addition to this you wanted the index to be renumbered...
having a
array_vaccum() would be nice...
eg..
$a = array("", "blah", "", "blah");
array_vaccum($a);
would make
$a[0] => "blah"
$a[1] => "blah"
writing this code in php_userspace would't be too hard but i can see this
being used by many people
function array_vaccum($a)
{
foreach($a as $b)
{
if($b != null)
$ret[] = $b;
}
return $ret;
}
and then you would need to worry about keys...
function array_avaccum($a)
{
$keys = array_keys($a);
foreach($keys as $key)
{
if($a[$key] != null)
$ret[$key] = $a[$key];
}
return $ret;
}
calling this code many many times would be way faster in the core code..?
wouldn't it?
--- [EMAIL PROTECTED] wrote:
> ID: 15280
> Updated by: mfischer
> Reported By: [EMAIL PROTECTED]
> Old Status: Open
> Status: Feedback
> Bug Type: Feature/Change Request
> Operating System: Win2k
> PHP Version: 4.1.1
> New Comment:
>
> You mean something like array_unset_empty_valus() ?
>
> I don't think there's a hard-coded need for it when user-space does it
> very well.
>
> Can you give an example (except your programming lazyness to create a
> function) where the advantages would be?
>
>
> Previous Comments:
> ------------------------------------------------------------------------
>
> [2002-01-29 13:30:10] [EMAIL PROTECTED]
>
> Hi,
>
> I have mailed with Gabor Hojtsy and he said to me that i request my
> wish here.
>
> This is a Copy - Paste of a part of the eMail:
>
> ###########
>
> I would like to have a function that deletes the empty array entries:
>
> a.e.
> $test[0] = "Hello i am php 4.1.1";
> $test[1] = "I am the best release ever :)";
> $test[2] = "";
> $test[3] = "";
>
> I hope you know what i mean...
>
> At the moment i have a loop that checkes this.
>
> $k = count($test);
> for($i=0;$i<=$k;$i++){
> if(empty($test[$i])) unset($test[$i]);
> }
>
> I think it would not be hard to integrate that. I am a apprentice and
> i
> will learn C/C++ after my php programming is well. I hope i could help
> bugfixing
> the next releases, to help you all.
>
> yours sincerly
> Benjamin Eggerstedt
>
> P.S. I know my english is terrible... ;)
> P.P.S. You all do GREAT work!!!
>
>
>
> ------------------------------------------------------------------------
>
>
>
> Edit this bug report at http://bugs.php.net/?id=15280&edit=1
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]