跪请

linzaifeng5859 2008-04-23 01:37:12
这是一道php的题目
<?php
$a = array("11"=>"aa","22"=>"bb","33"=>"cc","44"=>"dd","55"=>"ee","66"=>"ff","77"=>"hh");
$b = array("22","11","33","55","44","66","33");
如何能做到以下的结果,(其中$b集合"33"有两个)
$c = array("22"=>"bb","66"=>"ff","11"=>"aa","33"=>"cc","55"=>"ee","44"=>"dd","33"=>"cc");
要按照$b的顺序出结果
...全文
53 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ClintNorthwood 2008-04-23
这是哪位出的题?
回复
剑心永远OK 2008-04-23
$c = array("22"=>"bb","66"=>"ff","11"=>"aa","33"=>"cc","55"=>"ee","44"=>"dd","33"=>"cc");
这样根本是不可能做到的。
$c = array("22"=>"bb","66"=>"ff","11"=>"aa","33"=>array('cc','cc'),"55"=>"ee","44"=>"dd");
这样就可以做到。。

回复
linzaifeng5859 2008-04-23
不好意思,昨天帖子发错了,再请帮忙
回复
fcoolx 2008-04-23
$c = array("22"=>"bb","66"=>"ff","11"=>"aa","33"=>"cc","55"=>"ee","44"=>"dd","33"=>"cc");

这种有相同键名的数组是生成不了的

只能按照我上面的方式输出啊
回复
ten789 2008-04-23
跪着舒服
回复
fcoolx 2008-04-23
$a = array("11"=>"aa","22"=>"bb","33"=>"cc","44"=>"dd","55"=>"ee","66"=>"ff","77"=>"hh");
$b = array("22","11","33","55","44","66","33");
foreach ($b as $b1)
{
echo $a[$b1]."\n";
}
回复
沪php攻城师 2008-04-23
怎么又跑这里开个新贴了?原来帖子那里那么多答案你一个不用?
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2008-04-23 01:37
社区公告
暂无公告