Home  >  Article  >  Backend Development  >  弱弱的一个有关问题~

弱弱的一个有关问题~

WBOY
WBOYOriginal
2016-06-13 11:58:33902browse

弱弱的一个问题~~
$foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each($foo);
print_r($bar);
?>

哪位大大能详细解析一下吧=-=     搞不懂那个输出的结果
------解决方案--------------------
php系统函数没啥好解释的,知道怎么用就行
返回 array 数组中当前指针位置的键/值对并向前移动数组指针。键值对被返回为四个单元的数组,键名为 0,1,key 和 value。单元 0 和 key 包含有数组单元的键名,1 和 value 包含有数据。 

如果内部指针越过了数组的末端,则 each() 返回 FALSE。 

------解决方案--------------------
 $foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
foreach ($foo,$key,$value)
{
   echo "下标".$key."值:".$value;
}
//下面的应该会输出第一个元素
 $bar = each($foo);
 print_r($bar);
 ?>
------解决方案--------------------
php 的数组有两种表现形式:
一种是下标数组,以数字为下标访问
一种是关联数组,也名称为关联键访问
对于同一个数组元素,只能用之一

正因为如此 each 函数以两种形式返回数组的信息,供你选择使用

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