抓取foreach中数组值的序号(Grab ordinal number of the array value inside foreach)
你好,
我想在foreach循环中获取数组键的序号。
例
<?php $array = array("id" => 2, "username" => "foobar"); foreach($array as $value){ $array_key = search_array($value, $array); //find the ordinal number of $array_key from $array here. echo $value; }count返回数组中数组键的全部数量,我需要获取数组键的序号。 我希望你们明白我的要求。
Hello,
I want to grab the ordinal number of an array key inside a foreach loop.
Example
<?php $array = array("id" => 2, "username" => "foobar"); foreach($array as $value){ $array_key = search_array($value, $array); //find the ordinal number of $array_key from $array here. echo $value; }count returns the entire number of array keys in the array, i need to grab the ordinal number of the array key. I hope you guys understand what i ask.
更多推荐
发布评论