foreach($a as $key => $value),$key不是应该在变么?
我的数组是$a=array([0]=>(['name']=>aa)['id']=>1)[1]=>(['name']=>bb)['id']=>2)....[8]=>(['n...
我的数组是$a = array([0] => (['name'] => aa) ['id'] => 1)
[1] => (['name'] => bb) ['id'] =>2 )
..
..
[8] =>(['name'] => rr) ['id'] =>9))
foreach($a as $key => $value)之后打印$key的值永远是8 合理么?
我现在想把数组变成
$a = array([0] => (['name'] => aa) ['id'] => 1 ['url'] =>'前面id的对应值')
[1] => (['name'] => bb) ['id'] =>2 ['url'] =>'前面id的对应值')
..
..
[8] =>(['name'] => rr) ['id'] =>9 ['url'] =>'前面id的对应值' ))
因为要用[id]的值 所以选foreach 有没有好办法呢 ?我实在是没分了
我的数组是$a = array([0] => array(['name'] => aa) ['id'] => 1)
[1] => array(['name'] => bb) ['id'] =>2 )
..
..
[8] =>array(['name'] => rr) ['id'] =>9))
哦 应该是这样 展开
[1] => (['name'] => bb) ['id'] =>2 )
..
..
[8] =>(['name'] => rr) ['id'] =>9))
foreach($a as $key => $value)之后打印$key的值永远是8 合理么?
我现在想把数组变成
$a = array([0] => (['name'] => aa) ['id'] => 1 ['url'] =>'前面id的对应值')
[1] => (['name'] => bb) ['id'] =>2 ['url'] =>'前面id的对应值')
..
..
[8] =>(['name'] => rr) ['id'] =>9 ['url'] =>'前面id的对应值' ))
因为要用[id]的值 所以选foreach 有没有好办法呢 ?我实在是没分了
我的数组是$a = array([0] => array(['name'] => aa) ['id'] => 1)
[1] => array(['name'] => bb) ['id'] =>2 )
..
..
[8] =>array(['name'] => rr) ['id'] =>9))
哦 应该是这样 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询