php 遍历多维数组方法
在php中数组分类很多种,如一维数组,二维数组,三维或多维数组,下面我来给大家介绍php 遍历多维数组,有需要的朋友可参考。
在php遍历数组有三个函数foreach、each、list & each下面我们看它们是如何遍历多维数组的。
先看一个遍历二维数组
代码如下 | 复制代码 |
$sports = array( |
下面看遍历三维数组
例1
代码如下 | 复制代码 |
function arr_fun($arr){ |
例2
代码如下 | 复制代码 |
/* ';<br> print_r($arr1);<br> echo '<pre class="brush:php;toolbar:false">';<br> arr_foreach ($arr1);<br> ?> <p>输出结果</p> <p>Array<br> (<br> [1] => Array<br> (<br> [0] => 11<br> [1] => 12<br> [2] => 13<br> [14] => Array<br> (<br> [0] => 141<br> [1] => 142<br> )<br> )<br> [2] => 2<br> [3] => 3<br> [4] => 4<br> [5] => 5<br> )<br> 11<br> 12<br> 13<br> 141<br> 142<br> 2<br> 3<br> 4<br> 5</p> |
利用list与each遍历二维数组
代码如下 | 复制代码 |
$sports = array( while (list($key, $value) = each($sports)) { |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software