Results 1 to 10 of 42

Thread: Day 5 - Array - Become PHP Expert in 30 days

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    http://php.flashwebhost.com/vineesh/day5/array_1.php

    PHP Code:
    <?php

    $class 
    = array('lkg', 'ukg', 'i a', 'ii b', 'iii c', 'iv d', 'v a', 'vi c', 'vii d');

    echo 
    strtoupper($class [0]);
    echo 
    '<br>';
    echo 
    strtoupper($class [2]);
    echo 
    '<br>';
    echo 
    strtoupper($class [4]);
    echo 
    '<br>';
    echo 
    strtoupper($class [6]);
    echo 
    '<br>';
    echo 
    strtoupper($class [7]);
    http://php.flashwebhost.com/vineesh/...ay_numeric.php

    PHP Code:
    <?php

    $numbers 
    = array(9, 8, 7, 6, 5, 4, 3, 2, 1, 0);

    echo 
    $numbers [0];
    echo 
    '<br>';
    echo 
    $numbers [1];
    echo 
    '<br>';
    echo 
    $numbers [2];
    echo 
    '<br>';
    echo 
    $numbers [3];
    echo 
    '<br>';
    echo 
    $numbers [4];
    echo 
    '<br>';
    echo 
    $numbers [5];
    echo 
    '<br>';
    echo 
    $numbers [6];
    echo 
    '<br>';
    echo 
    $numbers [7];
    echo 
    '<br>';
    echo 
    $numbers [8];
    echo 
    '<br>';
    echo 
    $numbers [9];
    Last edited by vineesh; 05-15-2014 at 09:17 AM.

  2. #2
    Join Date
    Oct 2003
    Location
    Kochi, Kerala, India
    Posts
    21,389

    Default

    http://php.flashwebhost.com/vineesh/day5/day_5_1.php

    PHP Code:
    <?php
    $movieNames 
    = array('<h3> <font color="red">', 'kilukam', 'kalapani', 'minnaram', 'yoddha', 'spirit', 'drishyam', 'grand master', '</h3> 
    </font>'
    );

    echo 
    strtoupper('<h4> <font color=green> For Mohanlal fans, here are some of his superhit movies list: </h4> </fong> <br>');

    echo 
    strtoupper($movieNames[0]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[1]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[2]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[3]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[4]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[5]);
    -------------------------------------------
    http://php.flashwebhost.com/vineesh/day5/day_5_2.php

    PHP Code:
    <?php

    $movieNames 
    = array('kilukam', 'kalapani', 'minnaram', 'yoddha', 'spirit', 'drishyam', 'grand master');

    echo 
    strtoupper('<h4> <font color=red> For Mohanlal fans, here are some of his superhit movies list: </h4> </font>');

    echo 
    strtoupper($movieNames[0]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[1]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[2]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[3]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[4]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[5]);
    echo 
    '<br>';


    echo 
    '<pre>';

    echo 
    '<h2><font color=green>print_r() Example: </font></h2>';

    echo 
    print_r($movieNames);
    echo 
    '<br>';
    echo 
    '<h2><font color=blue>var_dump() Example:</font></h2>';
    echo 
    '<br>';
    echo 
    var_dump($movieNames);

    echo 
    '</pre>';
    -------------------------------------------
    http://php.flashwebhost.com/vineesh/day5/day_5_3.php

    PHP Code:
    <?php

    $movieNames 
    = array('kilukam', 'kalapani', 'minnaram', 'yoddha', 'spirit', 'drishyam', 'grand master');

    $numberOfMovies = count($movieNames);

    echo 
    strtoupper($movieNames[0]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[1]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[2]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[3]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[4]);
    echo 
    '<br>';
    echo 
    strtoupper($movieNames[5]);
    echo 
    '<br>';



    echo 
    '<br>';

    echo 
    'Above ' . $numberOfMovies . ' are Mohanlal\'s super hit movie names.';
    ------------------------------------------
    http://php.flashwebhost.com/vineesh/day5/day_5_4.php

    PHP Code:
    <?php

    $shirtBrands 
    = array('<font color=red><h2>', 'peter england', 'john players', 'van heusen', 'raymond', 'allen solly' , '</h2></font>');

    echo 
    strtoupper('This is how an Array prints using ') . 'foreach():';

    echo 
    '<pre>';
    foreach (
    $shirtBrands as $shirtBrandNames) {
        echo 
    strtoupper($shirtBrandNames);
        echo 
    '<br>';

    }
    ------------------------------------------
    http://php.flashwebhost.com/vineesh/day5/day_5_5.php

    PHP Code:
    <?php

    $myFriends 
    = array('suneesh', 'melbin', 'sibichan', 'tom');

    echo 
    '<pre>';
    print_r ($myFriends);
    echo 
    '<br>';

    echo 
    ucwords('I am going to add two more friends name to $myFriends array: <br>');

    $myFriends[] = 'ramesh';
    $myFriends[] = 'mini';


    echo 
    '<pre>';

    foreach(
    $myFriends as $friends) {
        echo 
    ucwords($friends);
        echo 
    '<br>';
    }

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
  •