PHP Programs

Program for Associative Array

In this program we demonstrate use of the Associative Array, An  Associative array with a string index each value can be assigned a specific key.

Program

<html>

<body>

<?php

/* First method to associate create array */

$salaries=array(

                  "x"=>200000,

                  "y"=>100000,

                  "z"=>50000

    );

echo"salary of x is=".$salaries['x']."<br/>";

echo"salary of y is=".$salaries['y']."<br/>";

echo"salary of z is=".$salaries['z']."<br/>";

/* Second method to create array. */

$salaries['x']="high";

$salaries['y']="medium";

$salaries['z']="low";

echo"Salary of x is= ".$salaries['x']."<br/>";

echo"Salary of y is=".$salaries['y']."<br/>";

echo"Salary of z is =".$salaries['z']."<br/>";

?>

</body>

</html>

When Run The Program Following Output:

salary of x is=200000

salary of y is=100000

salary of z is=50000

Salary of x is= high

Salary of y is=medium

Salary of z is =low

Description

Releted Programs

© 2017 codewmAll rights reserved.