Indexed Array in PHP – website development

In this video

This tutorial is about Indexed Array in PHP. In our last lecture we learned about Find Random Element from Array in PHP. If you haven’t watched it yet then here is the link of tutorial http://tutorialhive.net/2018/10/31/find-random-element-from-array-in-php/

Indexed Array in PHP

In this tutorial we will learn about Indexed Array in PHP. An array is a data structure that stores one or more similar type of values in a single value, so for example if you want to store 100 numbers then instead of defining 100 variables its easy to define an array of 100 length.

Numeric array/Indexed array

An array with a numeric index. Values are stored and accessed in linear fashion.

Array function

In PHP, the array() function is used to create an array:

array();

Create Indexed Array

There are two ways to create indexed arrays:

The index can be assigned automatically (index always starts at 0), like this:

$c = array(“Volvo”, “BMW”);

or the index can be assigned manually:

$c[0] = “Volvo”;

$c[1] = “BMW”;

so these are two ways to create indexes array , so code for first method is here.

<?php

$cars = array(“Volvo”, “BMW”, “Toyota”);

echo “I like ” . $cars[0] . “, ” . $cars[1] . ” and ” . $cars[2] . “.”;

?>

Output: I like Volvo, BMW and Toyota.

Indexed Array in PHP tutorial end here, so then next we will learn about Associative Array in PHP. If you have any queries you can ask us on our Facebook page link is given below, Thank you for watching us.

ABOUT US

Tutorial Hive’s mission is to provide quality education to all our community. Tutorial Hive’s mission is to provide free education to all those who cannot afford BIG FEE of institutes. We aim specifically to empower youth to understand programming related knowledge which further helps the society to reduce complex problems through applications. Why Tutorial Hive? We not only provide the theoretical knowledge but also provide the actual implementation with working sample applications. Tutorial Hive cannot achieve its mission without the help of our community. So, please if you think you can help in any manner feel free to contact us. Or if you see any mistake in our content which can be modified/corrected then please leave us a message

We are always open for suggestions.

Facebook: www.facebook.com/hbss2015

Subscribe on YouTube: https://www.youtube.com/channel/UCOUy6kTpedj7s6HOqM0c08w

 

Follow us on Social Media

You might be interested in

LEAVE YOUR COMMENT

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