The most viewed posts

Registry Reviver

Contact Me

Web Development Services

Computer Repair and Maintenance Service

How to clean up Windows Computer

Driver Booster

CCleaner

Myanmar font and keyboard for Windows

About Desktop Icons in Windows Computer

How to make a computer secure and run faster

The most viewed items

Dell Inspiron 5559

SONY Playstation Portable

Desktop Hard Disk

Laptop RAM

HP ProBook 430

Laptop

External Hard Disk

Please login to start chat

ZilaStar ICT Jun 12 2019, 12:15:54

Array in php

 Normally There are three types of array: Indexed Array, Associative Array and Multi-Dimentional Array.

1. Indexed Array (Works with number)

<?php
$snack = array('Banana', 'Ice-cream', 'Coconet', 'Mango', 'Orange');
$snack[1]='Alcohol';
echo $snack[1];
//print_r($snack);
?>
 

 2. Associative Array (Works with name)

<?php
$snack = array('Banana' => 100, 'Apple' => 200, 'Cake' => 300);
echo 'The cake is '.$snack['Cake']. ' Kyat.';
?>


3. Multi-Dimentional Array

<?php
$food = array('Healthy'=>array('Salad'=>200, 'Milk'=>100, 'Coconet'=>200),
              'Unhealthy'=>array('Alcohol'=>200, 'Beer'=>300));

foreach($food as $element => $inner_array){
  echo '<br /><strong>'.$element.'</strong><br />';
  foreach($inner_array as $inner_element => $item){
    echo $inner_element.' = '.$item.'<br />';
  }
}
?>

 

  • To Contact
    Available Services
    Terms and Conditions