How to get array length in a solidity| Solidity by example

The array is a fixed or dynamic compile time in solidity.

Sometimes, We want to find the array length to check several elements in Solidity.

Solidity Array provides a length property to return the number of array elements in it.

How to find the length of an array in solidity

First, Array is created by initializing static data. Next, create a size() public function which returns the count of elements in an array. length property returns the number of elements in an array

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;

contract test {
   string[3] numbers=["one","two","three"];

    function size() public view returns(uint){
            return numbers.length;;



    "0": "uint256: 3"