Home  >  Article  >  Backend Development  >  Explain relevant examples of PHP array traversal

Explain relevant examples of PHP array traversal

jacklove
jackloveOriginal
2018-06-08 11:21:061859browse

Traverse the array: It means going through each one once. This article will explain the relevant examples.

1) for loop

is rarely used because it has defects

'傻逼',
        'num'=>10
);
/*
foreach($arr1 as $value){
    echo $value.'
';
}
*/
foreach($arr1 as $key=>$value){
    echo $key.'=>'.$value.'
';
}
?>
';
    }
}
?>
';
foreach ($students as $val){
    if($val[2]===true){
        $val[2]='男';
    }else{
        $val[2]='女';
    }
    echo "{$val[0]}{$val[1]}{$val[2]}{$val[3]}";
}
echo '';
?>

This article explains related examples of PHP array traversal, more For related content, please pay attention to php Chinese website.

Related recommendations:

Explain PHP array classification and array creation methods

Explain the predefined superglobal of PHP arrays Array variables

Explanation on PHP language tags, command separators, and comments


The above is the detailed content of Explain relevant examples of PHP array traversal. 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