因为Foreach是数组遍历。
你没有2这个Key。所以不会出现你所说的情况
你没有2这个Key。所以不会出现你所说的情况
解决方案 »
- phpDesigner问题
- 菜鸟求教关于mysql防注入
- php有没有类似asp.net的datatable.select()的功能?
- phpmyadmin无法查看数据表的结构是怎么回事呢
- php+mysql select a.*,b.* from tb1 as a,tb2 as b的查询问题
- 怎样用JavaScript实现像QQ那样一有消息窗口就会在任务栏中一闪一闪,我想把这用在我的聊天室里。
- PHP加密的思路。
- PHP小问题,望指教!
- PHP与JS的问题,急,在线等。。。
- mysql的错误
- PHP如何访问Access?一定给分~~
- 100分重奖:PHP网站开发,系统架构说明。。。请高手留下QQ号码
/* foreach example 4: multi-dimensional arrays */$a[0][0] = "a";
$a[0][1] = "b";
$a[1][0] = "y";
$a[1][1] = "z";foreach($a as $v1) {
foreach ($v1 as $v2) {
print "$v2\n";
}
}
ksort那?
(PHP 3, PHP 4 )ksort -- Sort an array by key
Description
int ksort ( array array [, int sort_flags])
Sorts an array by key, maintaining key to data correlations. This is useful mainly for associative arrays. Example 1. ksort() example$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
This example would display: a = orange
b = banana
c = apple
d = lemon
You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort(). See also asort(), arsort(), krsort(), uksort(), sort(), natsort(), and rsort(). Note: The second parameter was added in PHP 4.
asort
(PHP 3, PHP 4 )asort -- Sort an array and maintain index association
Description
void asort ( array array [, int sort_flags])
This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. Example 1. asort() example$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
asort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
This example would display: c = apple
b = banana
d = lemon
a = orange
The fruits have been sorted in alphabetical order, and the index associated with each element has been maintained. You may modify the behavior of the sort using the optional parameter sort_flags, for details see sort(). See also arsort(), rsort(), ksort(), and sort().