In Associative array data will store through String index value .For example To store the student marks in an array. We store the each student marks with there own name. The name are stored as index and marks as there values.
$marks = array("Ali" => 400, "Javeed" => 600, "Azra" => 500) ;
you can print these valu
echo $marks['Ali'] . "
"; echo $marks['Javeed'] . "
"; echo $marks['Azra'] . "
";
You can also use the forech loop which is best way of retrieving the data form array.
foreach($marks as $x => $x_value) { echo "name=" . $x . "Marks=" . $x_value . "
" ; } ?>
You also store the data in two dimensional string index array or in Associative array.
For example we create a Two dimensional with string Index. In which store the Name ,marks, and Grade of Student.
array('Marks' => 500, 'Grade' => "A"), "Qasim"=> array('Marks' => 530, 'Grade' => "A"), "Javeed"=> array('Marks' => 450, 'Grade' => "B") ); ?>
You can display these value form two dimension string index array in the following way:
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function