Recent projects have such a requirement for arrays. The contents of the array itself may keep changing. If you know a certain key name of the array, how to get the next key name?
At first I thought it would be difficult to write, so I kept looking for array-related functions in books and searching online, but found none.
So I started writing it myself, and I didn’t expect it to be so easy.
[html]
/*
* Find the next key name of the current key name in the array
* $array array
* $keys Current key name
* Return the next key name
*/
function next_array($array,$keys){
$n=0;
foreach($array as $key =>$value){
if($n==1)
return $key;
if($key == $keys)
$n++;
}
}
I found that many times, you still have to rely on yourself.
http://www.bkjia.com/PHPjc/477630.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477630.htmlTechArticleRecent projects need to have such a requirement for arrays. The content of the array itself may continue to change. If you know some of the array A key name, how to get the next key name? At the beginning...
Statement: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