Home > Backend Development > PHP Tutorial > Introduction to the usage of (foreach) in php_PHP tutorial

Introduction to the usage of (foreach) in php_PHP tutorial

WBOY
Release: 2016-07-12 09:06:19
Original
873 people have browsed it

Introduction to the usage of (foreach) in php

foreach ($array as $key => $value)
foreach can only be used for arrays. In each loop, the key name of the current unit will also be assigned to the variable $key in each loop. The value of the current cell is assigned to $value and the pointer inside the array is moved forward one step.
$arr=array(0=>"Hello",1=>"World",2=>"Friends");
//var_dump($arr);
foreach ($arr as $key=>$vol){
echo "This is the result of the key-value pair ".$key."----".$vol."
";
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1065653.htmlTechArticleIntroduction to (foreach) usage in php foreach ($array as $key = $value) foreach can only be used for arrays , in each loop, the key name of the current unit will also be assigned to the variable $key in each loop. When...
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