John:

How do you plan to "remove" an $array[2]?

If you are using associative arrays, then you can remove an element using the unset() function, and then the answer to your question is "yes", so to speak:

For example:

<?php
function test_print ($item2, $key)
{
    echo "$key       $item2<br>\n";
}

$array = array( 'first' => 'one', 'second' => 'two', 'third' => 'three', 'fourth' => 'four' );

print "before<br>\n";
array_walk($array, test_print);
print "<br><br>\n";

unset($array['second']);

print "after<br>\n";
array_walk($array, test_print);
?>

produces this output:

before
first                 one
second                 two
third                 three
fourth                 four


after first one third three fourth four

Hope this helps

On Tuesday, September 2, 2003, at 09:40 PM, John Macon wrote:

I have a quick question about arrays. I know that this is probably pretty easy for most of you out there, so here it goes.

If you remove $array[2], would $array[3] then automatically become the new $array[2]?

Thanks in advance for your help.
* * * * * * * * * * * * * * * * * * * * * * * * * * *
J. Suzanne Flowers                      [EMAIL PROTECTED]
JustAboutData.com                       
http://www.justaboutdata.com

Because you need data, to test it right!

Reply via email to