<?php
$fruit = array('apple', 'banana', 'peach', 'pear');
foreach( $fruit as $key => $val ){
if( $val == 'banana' ){
unset( $fruit[$key] ); //takes away index
}
}
echo '<pre>';
print_r($fruit); // show the resulting array
This works, too.
Result
Array
(
[0] => apple
[2] => peach
[3] => pear
)
One little problem is how to get keys to be 0,1,2
I do not remember how to do .......
How can we get to here??????
Array
(
[0] => apple
[1] => peach
[2] => pear
)