If you want to access an individual value form an indexed, associative or multidimensional array you can either do it through using the array index or key.
Let's check out the following example to understand how it basically works:
<?php
// Indexed array
$sports = array("Baseball", "Cricket", "Football", "Shooting");
// Associative array
$cities = array("France"=>"Paris", "India"=>"Mumbai", "UK"=>"London", "USA"=>"New York");
// Multidimensional array
$superheroes = array(
array(
"name" => "Peter Parker",
"character" => "Spider-Man",
),
array(
"name" => "Tony Stark",
"character" => "Iron-Man",
),
array(
"name" => "Clark Kent",
"character" => "Super-Man",
)
);
echo $sports[0]; // Outputs: Baseball
echo "<br>";
echo $sports[1]; // Outputs: Cricket
echo "<br>";
echo $cities["France"]; // Outputs: Paris
echo "<br>";
echo $cities["USA"]; // Outputs: New York
echo "<br>";
echo $superheroes[0]["name"]; // Outputs: Peter Parker
echo "<br>";
echo $superheroes[1]["character"]; // Outputs: Iron-Man
?>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Passwordless Login with Laravel 8
Laravel provides simple authentication s...Angular 12 HTTP get request example using HttpClient module
Every front-end application needs to com...How to Scroll to the Top of the Page Using jQuery/JavaScript
Use the scrollTop Property You can us...How to use jQuery knob in your website
jQuery Knob is the simple jQuery plugin...How to Remove Duplicate Values from an Array in PHP
In this article, i will share with you h...