PHP数组,$a = {0,1,2,3}怎样变成$a = {1,2,3,4]
PHP数组,$a = {0,1,2,3}怎样变成$a = {1,2,3,4]。就是多维数组的维,然后把维加1,输出成表格的序列号,1,2,3,4
------解决方案--------------------
$a = array(0, 1, 2, 3);<br />$b = range(1, count($a));<br />$c = array_combine($b, $a);<br />print_r($c);
$arr = array(0,1,2,3);<br />$temp = array();<br />foreach($arr as $k=>$v){<br /> $k++;<br /> $temp[] = $k;<br />}<br />print_r($temp);<br />
<br /><?php<br />$a = array(0,1,2,3);<br />array_unshift($a, 0); // 在数组开头插入一个新元素,使key自增1<br />unset($a[0]); // 删除开头新增的元素,但key保持不变<br />print_r($a); // 输出<br />?><br />