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/
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.
An array with a numeric index. Values are stored and accessed in linear fashion.
In PHP, the array() function is used to create an 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 = “Volvo”;
$c = “BMW”;
so these are two ways to create indexes array , so code for first method is here.
$cars = array(“Volvo”, “BMW”, “Toyota”);
echo “I like ” . $cars . “, ” . $cars . ” and ” . $cars . “.”;
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.
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.
Subscribe on YouTube: https://www.youtube.com/channel/UCOUy6kTpedj7s6HOqM0c08w
Follow us on Social Media