PHP Check If Array Is Multidimensional or Not

In this tutorial, we will discuss check if the array is multidimensional or not in PHP. This post will give you a simple example of PHP to determine if array is multidimensional. We will look at example of PHP check array is multidimensional. I would like to share with you how to check if the array is a multidimensional PHP. Here, Creating a basic example of check if the array is a multidimensional PHP example.

Here, I will give you a very simple example of how to check if array is multidimensional or not in PHP. sometimes we need to check given array is a single-dimensional or multidimensional in PHP, so basically we can write code on according to the type of that array.

In this exampl we will create isMultiArray() with array argument. we have to pass array as argument and fuinction will check if array if multidimensional using rsort(), isset() and is_array() php function.

So, here bellow simple example of checking array is multidimensional or not in PHP, let’s see:


    $mySingleArray = [1, 2, 3, 4, 5];
    $myMultiArray = [
        ["id"=>1, "name"=>"america"],
        ["id"=>2, "name"=>"india"],
        ["id"=>3, "name"=>"canada"],
    function isMultiArray($arr) { 
        return isset($arr[0]) && is_array($arr[0]); 


we hope it can help you…

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker