search
HomeBackend DevelopmentPHP ProblemHow to determine the dimensionality of an array in php

php method to determine the dimensionality of an array: first create a PHP sample file; then define a TestArray function; finally, traverse the foreach and "is_array" functions to determine the dimensionality of the array.

How to determine the dimensionality of an array in php

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

PHP checks whether the current array is a multi-dimensional array

/**
 * [TestArray 检测数组是一维还是二维]
 * @E-mial wuliqiang_aa@163.com
 * @TIME   2017-04-07
 * @WEB    http://blog.iinu.com.cn
 * @param [type] $array [数组]
 */
function TestArray($array){
    foreach($array as $v){
        if(is_array($v)){
            $Int_Array = array('status'=>2,'return'=>'检测为二维数组');
        }else{
            $Int_Array = array('status'=>1,'return'=>'检测为一维数组');
        }
    }
    return $Int_Array;
}

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of How to determine the dimensionality of an array in php. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools