click below button to copy the code. php tutorial - team
php examples Code Explanation :
In this statement we define the associative array for the variable “$var1” by using array function and its value is declared by “key” in which, more than one values are separated by using commas (,) like “$var1=array (“samp1” =>” zero”, “samp2” =>”one”, “samp3” =>” two”) and finally the declaration end with semicolon (;).
Echo statement echo "samp1 value-" .$var1['samp1']; will print the key with its string value. Same thing applies for the other two echo statements.
php tutorials Sample Output :
Here in this output, for the key “samp 1” with its value “zero” has been printed in the output as “samp1 value-zero”.
Here in this output, for the key “samp 2” with its value “one” has been printed in the output as “samp2 value-one”.
Here in this output, for the key “samp 3” with its value “two” has been printed in the output as “samp3 value-two”.