开发者

How to get position in a php associative array? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

php - get numeric index of associative array

$array = ('开发者_如何学JAVAa'=>'a', 'b'=>'b');
foreach($array as $key => $value ){
   //echo $position ( 1,2 )
}

Can I get the position in the array with a simple function ?


Try:

$i = 0;
$array = ('a'=>'a', 'b'=>'b');
foreach($array as $key => $value ){
   $i++;
   echo $i;
}


$array = array('a'=>'a', 'b'=>'b');
for ($x = 0; $x < count($array);$x++)
        echo $x."<br >";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜