PHP Code Example on Associative Array and Multidimensional Array

PHP Code Example on Associative Array and Multidimensional Array

PHP Video Tutorial

“Learn the PHP basics from 17 info packed video tutorials.” “On CD”
Current Bid: $1.99

PHP code, PHP example, An example source code for php associative and multidimensional array.

Arrays are very important in every programming languages. In this hub you will see another example of php code on the other types of array, the associative and the multidimensional array. You will see the difference between the two and you will learn on how to use them in your coding on a PHP Editor.

Please note that in coding PHP, you must have a PHP editor like notepad++, a php server like apache and much better if you have a database server too like mysql. To have both apache and mysql you might want to download xaamp for free just google it.

To run the sample source codes you must, at a least, know how to run a php code in your browser. If you have a problem on running a php code on your browser, please refer to the link below for some simple easy steps on executing php codes or php scripts.

PHP Books

2002 PROGRAMMING PHP creating dynamic Web pages BEGINNER software development
Current Bid: $5.00
Multi-Tier Application Programming with PHP: Practical
Current Bid: $9.11

How to run a PHP code on your browser using XAAMP and Notepad++.

If you do not know how to run an HTML code on your browser, you may check the following link too.

Learn the basic of HTML: How to create an offline webpage

To know more about associative and multidimensional arrays, refer to the source code below. You can study and trace the codes and learn how the outputs happen.

Sample PHP Code for Associative Array

“ID Number: 00120”, “N. Smith”=> “ID Number: 00121”,
“M. Maclein” => “ID Number: 00122”, “A. Garfield” => “ID Number: 00123”, “R. Rutherford” => “ID Number: 00124”);
$count = count($student);
echo “Associative Array Example Output”. ”
“;
echo “Student Name: J. Parker “.$student[‘J. Parker’]. ”
“;
echo “Student Name: N. Smith “.$student[‘N. Smith’]. ”
“;
echo “Student Name: M. Maclein “.$student[‘M. Maclein’]. ”
“;
echo “Studet Name: A. Garfield “.$student[‘A. Garfield’]. ”
“;
echo “Student Name: R. Rutherford “.$student[‘R. Rutherford’]. ”
“;
?>

Sample Output for Associative Array

See all 2 photos

Sample PHP Code of Multidimensional Array

array(“J. Parker”, “N. Smith”, “M. Maclein”),
“Section B” => array(“R. Rutherford”, “A. Swan”, “L. Go”),
“Section C” => array(“C. Wilson”, “N. Tucker”, “Z. Page”));
$count = count($section);
echo “The students on Section A Are:
“;
for($i=0; $i<$count; $i++) { echo $section['Section A'][$i]. " "; } echo " "; echo "The students on Section B Are: "; for($i=0; $i<$count; $i++) { echo $section['Section B'][$i]. " "; } echo " "; echo "The students on Section C Are: "; for($i=0; $i<$count; $i++) { echo $section['Section C'][$i]. " "; } ?>

Sample Output for Multidimensional Array

See all 2 photos

Cool Android Phones!

HTC Droid Incredible Verizon Wireless Wifi 8.0 MP Camera 8GB Android Cell Phone
Current Bid: $64.95
NEW 4″ Multi-Touch Android 4.0 Smart Phone Dual SIM WIFI Unlocked AT&T T-Mobile
Current Bid: $63.96
NEW 4″ Multi-Touch Android 4.0 Smart Phone Dual SIM WIFI Unlocked AT T T-Mobile
Current Bid: $63.96

Eye Protector for Computer Users

BLACK OR BROWN WAYFARER COMPUTER GLASSES-ANTI REFLECTIVE COATING- UV PROTECTION
Current Bid: $7.99
How to become a PHP Developer: Learn and Earn
Steps on How to Program in PHP: A Beginner’s Guide on PHP Programming-Part 1
How to run PHP Code or PHP Scripts and See the Result on Your Browser
HTML Basics: Learn The Basics of HTML and Create Your Own Webpage on Your Browser
PHP Sample Codes On Function:How to make Function in PHP
PHP Code Example on Foreach Loop and For Loop
PHP code Example for if statement
PHP Code Example for if-else Statement
PHP Code Example on if else-if Statement
PHP Code Example on Switch Statement
PHP Code Example on While Loop
PHP Code Example on Numeric Array
PHP Code Example on Do-while Loop