以下代码,
$test_array = array("a","b","c","d","e");
echo "<fieldset><pre>";
htmlspecialchars(print_r($test_array));
echo "</pre></fieldset>";
给出输出,
Array
(
[0] => a
[1] => b
[2] => c
[3] => d
[4] => e
)
我想从索引2中删除一个特定的条目并重新索引数组,如下所示
Array
(
[0] => a
[1] => b
[2] => d
[3] => e
)
怎么做?
答案 0 :(得分:2)
答案 1 :(得分:1)
试试这个
unset($test_array[2]);
$test_array = array_values($test_array);