Results 1 to 10 of 27

Thread: Day 6 - Associative Array - Become PHP Expert in 30 days

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default

    http://php.flashwebhost.com/sibichan...ray_2_eg_2.php

    PHP Code:

    <?php


    $monitor 
    = array();

    $monitor1 ['brand'] = 'Dell';

    $monitor1 ['size'] = 27;

    $monitor1 ['price'] = 6000;

    $monitor2 = array();

    $monitor2 ['brand'] = 'Viewsonic';

    $monitor2 ['size'] = 23;

    $monitor2 ['price'] = 2000;

    $monitor3 =array ();

    $monitor3 ['brand'] = 'Samsung';

    $monitor3 ['size'] = 24;

    $monitor3 ['price'] = 4000;

    $monitor4 = array();

    $monitor4 ['brand'] = 'LG';

    $monitor4 ['size'] = 19;

    $monitor4 ['price'] = 1500;

    $monitor[] = $monitor1;

    $monitor[] = $monitor2;

    $monitor[] = $monitor3;

    $monitor[] = $monitor4;


    foreach (
    $monitor as $ledMonitor)  

      {

    echo 
    ' Brand : ' $ledMonitor['brand'] . '<br>';

    echo 
    ' Size : ' $ledMonitor['size'] .'" ' '<br>';

    echo 
    ' Price : ' $ledMonitor['price'] . '<br>';

    if (
    $ledMonitor['price'] <=2000 ) {

    echo 
    '<div style=color:red;font-weight:bold>Exclusive offer !</div>';}

    elseif (
    $ledMonitor['price'] <=4000 ){

    echo 
    '<div style=color:#0033ff;font-weight:bold>HURRY ! . Limitted-time offer !</div>';

    }

    else {   

     echo 
    '<div style=color:#009900;font-weight:bold>Premium offer. FREE multimedia speakers. Before.<span style=text-decoration:line-through>Rs. 7,699</span></div>';

    }

    echo 
    '<hr>';

    }
    Last edited by Vahaa11; 05-15-2014 at 11:13 AM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •