php 数组重新排序 数字键名key
======把数组$arr:======Array([0]=>ez6svdzre[2]=>k8e4jq3dp[34]=>ua9nywn[36]=>fymt6syf[n]=...
======
把数组$arr :
======
Array
(
[0] => ez6svdzre
[2] => k8e4jq3dp
[34] => ua9nywn
[36] => fymt6syf
[n] => *******
)
======
变成$arr1 :
======
Array
(
[0] => ez6svdzre
[1] => k8e4jq3dp
[2] => ua9nywn
[3] => fymt6syf
[n] => *******
) 展开
把数组$arr :
======
Array
(
[0] => ez6svdzre
[2] => k8e4jq3dp
[34] => ua9nywn
[36] => fymt6syf
[n] => *******
)
======
变成$arr1 :
======
Array
(
[0] => ez6svdzre
[1] => k8e4jq3dp
[2] => ua9nywn
[3] => fymt6syf
[n] => *******
) 展开
展开全部
$array = array(
0 => "ez6svdzre",
2 => "k8e4jq3dp",
34 => "ua9nywn",
36 =>"fymt6syf",
n => "*******"
);
while ($value = current($array))
{
$arr[] = $value;
next($array);
}
var_dump($arr);
0 => "ez6svdzre",
2 => "k8e4jq3dp",
34 => "ua9nywn",
36 =>"fymt6syf",
n => "*******"
);
while ($value = current($array))
{
$arr[] = $value;
next($array);
}
var_dump($arr);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ksort 函数
<?php
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
?>
显示:
a = orange
b = banana
c = apple
d = lemon
<?php
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
?>
显示:
a = orange
b = banana
c = apple
d = lemon
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
array_values($arr);
正解!
正解!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
print_r(array_values($arr));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
ksrot($arr1);
array_values($arr1);
array_values($arr1);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询