Php

How to print array values in php using mysql – associative array

Google+ Pinterest LinkedIn Tumblr

Associative array is array that use named keys that you assign to them.

example

<?php

$var2 = array('raj'='123','sekar'=>'213','developer'=>'545','desks'=>'345');

echo $var2['raj']; // output is 123
echo $var2['sekar']; // output is 213
echo $var2['developer']; // output is 545
echo $var2['desks']; // output is 345

?>

named key ‘raj’ has vlaue ‘123’;

IF the named key is unknown and unlimited the use foreach

<?php

$var3 = array('raj'='123','sekar'='213','developer'='545','desks'='345','php'='34','html'='54654','css'='123'); 

foreach($var3 as $X=>$value)
{
echo $X .$value;
}

?>

output

raj 123
sekar 213
developer
545
desks 345
php 34
html 54654
css 123

Similar like Associative array

Multidimensional Array concept in Php

A multidimensional array is an array containing one or more arrays.

Its is solution for to know how to handle a array with in array
Example
1.Two-dimensional array
2.Three-dimensional array

Here You can see Exaplaination

 

I'm Rajasekar - Web developer, Freelancer, Blogger and Owner of DeveloperDesks. From India lives in Bahrain. I love to do coding, Creating websites and trying different with code and designs. You Can Hire Me