Implementation code for deleting elements in the php array. Copy the code as follows :? Php $ arrarray (a, B, c, d); unset ($ arr [1]); print_r ($ arr );? After print_r ($ arr), the result is not that. The final result is Array ([0] a [2].
The code is as follows:
$ Arr = array ('A', 'B', 'C', 'D ');
Unset ($ arr [1]);
Print_r ($ arr );
?>
After print_r ($ arr), the result is not that. The final result is Array ([0] => a [2] => c [3] => d
So how can we fill in the missing elements and re-index the array? The answer is array_splice ():
The code is as follows:
$ Arr = array ('A', 'B', 'C', 'D ');
Array_splice ($ arr, 1, 1 );
Print_r ($ arr); // Array ([0] => a [1] => c [2] => d)
?>
The http://www.bkjia.com/PHPjc/325527.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325527.htmlTechArticle code is as follows :? Php $ arr = array ('A', 'B', 'C', 'D'); unset ($ arr [1]); print_r ($ arr );? After print_r ($ arr), the result is not that. The final result is Array ([0] = a [2]...