PHP : Get the size of an array

In this tutorial learn how to get a size an array using the function with count method in php.



public static function size($array)
    {
        return count($array);
    }



TUTORIAL

<?php

$array = Array
(
    0 => Array
        (
            'user_id' => 10,
        ),

    2 => Array
        (
            'user_id' => 9,
        ),

    4 => Array
        (
            'user_id' => 8,
        )
);

 function size($array)
    {
        return count($array);
    }
    
echo size($array);
OUTPUT


3

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...