PHP array

Welcome to all our readers on our website at www.tutorialpath.com. As you all know that here on our website we will provide you lots of information related to the latest and newly introduced technology which help you to get updated with the latest tech. Here you will get all the useful information which is required in this tech world. As you know technology is one of the trending part in this world. So, here again we came up with a latest and new tech information which is related to the process of creating PHP Array . With the help of this article you will get to know the complete process of how to create PHP array in a step by step manner. So, simply have a look to this article and grab all the useful information which is going to be very helpful for you.

PHP array

All the variables you have used have held only a single value.

An array is a special variable, which can hold more than one value at a time.

There are three types of array.

    • Indexed Array : An array with a numeric index.
    • Associative Array : Arrays with named keys.
    • Nesting Array(Multi-D array) : An array containing one or more array.

How to define array

Output:

 

1.Indexed Arrays:- There are two ways to create of indexed array.

Example:

$cars = array(“VOLVO”,”TATA”,”BMW”);

Example:

$car’s[0] = “VOLVO”;

$car’s[1] = “TATA”;

$car’s[2] = “BMW”;

  • GET the length of an array – The count() function.
  • The count() function is used to return the length (the number of elements) of an array.

Example:

Output:

2. Associative Arrays:-

  • Associative arrays are arrays that use name keys that you assign to them.
  • there are two ways to create an associative arrays.

Example:

$age = array(“peter”=>”35″,”Ben”=>”37”);

Example:

Output:

3. Multidimensional Arrays:-

  • A multidimensional Arrays is an array containing one or more arrays.

Example:

 

Output:

 

Conclusion:

So, hopefully we had shared all the basic steps which help you to PHP Array . If you are using any of the above given browser and the steps helps you to enable or disable the JavaScript then simply share this article with others and also tell us by dropping a comment in the comment section below so that we get to know how helpful this article is for you all.

Leave a Reply

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