求解数组序号及所在位置

WBOY
Release: 2016-06-23 13:58:44
Original
1105 people have browsed it

$arr = array (  0 =>   array (    0 => 'SU14031300617',    'po_num' => 'SU14031300617',  ),  1 =>   array (    0 => 'SU14031300623',    'po_num' => 'SU14031300623',  ),  2 =>   array (    0 => 'SU14031300626',    'po_num' => 'SU14031300626',  ),  3 =>   array (    0 => 'SU14031300627',    'po_num' => 'SU14031300627',  ),  4 =>   array (    0 => 'SU14031300616',    'po_num' => 'SU14031300616',  ),  5 =>   array (    0 => 'SU14031300618',    'po_num' => 'SU14031300618',  ),  6 =>   array (    0 => 'SU14031300622',    'po_num' => 'SU14031300622',  ),  7 =>   array (    0 => 'SU14031300624',    'po_num' => 'SU14031300624',  ),  8 =>   array (    0 => 'SU14031300625',    'po_num' => 'SU14031300625',  ),)
Copy after login


假设SU14031300617这项,所在数组的位置是8项中的第1项,表示为 1/8,通过序号可求得。请问怎么求解?


回复讨论(解决方案)

foreach($arr as $k=>$tmp) {    if('SU14031300617' == $tmp[0]) {        return ($k+1) . '/' . count($arr);    }}return false;
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!