$val){...}}"."/> $val){...}}".">

Home  >  Article  >  Backend Development  >  What does php traversal mean?

What does php traversal mean?

藏色散人
藏色散人Original
2020-10-08 16:44:472850browse

PHP traversal refers to traversing an array, which means taking out the elements in the array. PHP traversal statements such as "foreach($arr_m as $value){foreach($value AS $key => $val){ ...}}".

What does php traversal mean?

Recommended: "PHP Video Tutorial"

php traversal refers to traversing the array

That's it Take out the elements from the array. .

For example

$arr = array(
'a' => 1,
'b' => 2,
'c' => 3,
'd' => 4
);
foreach($a AS $k => $v)
{
echo $k.'的值是'.$v;
}

This is a 2-dimensional array, and a double-layer loop must be used. .

If you want to output more content, you can try my modified code.

23,'name'=>'小红','age'=>23),
array('id'=>15,'name'=>'小白','age'=>21),
array('id'=>12,'name'=>'小黑','age'=>31),
array('id'=>2,'name'=>'小二','age'=>31)
);
$arr_id = array();
$arr_age = array();
foreach($arr_m as $value)
{
foreach($value AS $key => $val)
{
echo $key.'是'.$val .'
'; } echo '

'; } ?>

The above is the detailed content of What does php traversal mean?. For more information, please follow other related articles on the PHP Chinese website!

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