| how to delete array element with shifting the indexes ?
|
PHPycho

msg:3632119 | 9:24 am on Apr 22, 2008 (gmt 0) | hello forums! Can anybody suggest in the following case: How to remove an element from an index array and reseting its indexes? Example: [PHP]$array = array('x', 'y', 'z',..); unset($array[1]); print_r($array); // results: 0 => x, 2 => z ,which doesn't reset the indexes // I would like to have the result as : 0 => x, 1 => z , ie rearraning the indexes[/PHP] How to accomplish this ? Thanks in advance for the suggestions.
|
Habtom

msg:3632150 | 10:12 am on Apr 22, 2008 (gmt 0) | You can add this line right after unset $b = array_values($a); ...and test: print_r($b) More about it here [php.net]
|
xiongbin

msg:3659697 | 8:42 am on May 27, 2008 (gmt 0) | array_splice($x,1,1); print_r($x);
|
|
|