1.

How to get single value from array in php?

Answer»

In PHP, if you want to ACCESS a single VALUE from an array, be it a numeric, indexed, multidimensional or associative array, you NEED to use the array index or key.
Here’s an example using a multidimensional array:

Example

$superheroes = array(
array(
"name" => "Name",
"character" => "BestInterviewQuestion",
),
array(
"name" => "CLASS",
"character" => "MCA",
),
array(
"name" => "ROLL",
"character" => "32",
)
);
ECHO $superheroes[1]["name"];

 

Output:

CLASS



Discussion

No Comment Found