Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 42

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

  1. #31
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 5 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/array_count.php

    Code:
    <?php
    
    
    $mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
    
    
    $numberOfMovies = count($mohanlalMovies);
    
    
    echo 'Mohanlal acted ' . $numberOfMovies .' in last 2 years';
    
    
    echo '<br>';
    
    
    
    
    $mohanlalHitMovies = array('Drishyam', 'Narasimham', 'Aaram Thampuran', 'Spadikam', 'Thenmavin Kombathu', 'Manichithrathazhu', 'Devasuram', 'Kilukkam', 'Chithram', 'Irupatham Noottandu');
    
    
    $numberOfHitMovies = count($mohanlalHitMovies);
    
    
    echo 'Mohanlal has ' . $numberOfHitMovies . ' All Time Record Blockbustors';

  2. #32
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 5 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/array_foreach.php

    Code:
    <?php
    
    
    $mohanlalHitMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
    
    
    foreach($mohanlalHitMovies as $mohanlalMovies) {
    
    
    echo $mohanlalMovies;
    
    
    echo '<br>';
    
    
    }

  3. #33
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    http://php.flashwebhost.com/sherly/Vegetables0.php

    Code:
    <?php
    
    // create array
    
    $vegetables = array('tomato', 'potato', 'cucumber', 'carrot', 'spinach', 'cabbage', 'chilli');
    
    // lets print
    
    echo '<pre>';
    
    print_r($vegetables);
    //var_dump($vegetables);
    
    echo '</pre>';

  4. #34
    Join Date
    Nov 2009
    Posts
    76,596

    Default

    http://php.flashwebhost.com/sherly/Vegetables2.php

    Code:
     <?php
    
    // create array
    
    $vegetables = array('tomato', 'potato', 'cucumber', 'carrot', 'spinach', 'cabbage', 'chilli');
    
    $numberOfVegetables= count($vegetables);
    
    echo '<p>We have ' . $numberOfVegetables . ' fresh vegetables in our store.</p>';

  5. #35
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    Quote Originally Posted by sherlyk View Post
    http://php.flashwebhost.com/sherly/Vegetables0.php
    Code:
    <?php
    
    // create array
    
    $vegetables = array('tomato', 'potato', 'cucumber', 'carrot', 'spinach', 'cabbage', 'chilli');
    
    // lets print
    
    echo '<pre>';
    
    print_r($vegetables);
    //var_dump($vegetables);
    
    echo '</pre>';
    Good, keep file names always smaller cause as a standard.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  6. #36
    Join Date
    Feb 2007
    Posts
    26,214

    Default

    DAY 5 PHP PROGRAMMING

    http://php.flashwebhost.com/tom/array_add.php

    Code:
    <?php
    
    
    $mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
    
    
    echo '<pre>';
    
    
    var_dump($mohanlalMovies);
    
    
    echo '</pre>';
    
    
    echo '<p>I am going to add 3 more movies to $mohanlalMovies array</p>';
    
    
    $mohanlalMovies[] = 'Christian Brothers';
    $mohanlalMovies[] = 'China Town';
    $mohanlalMovies[] = 'Shikkar';
    
    
    echo '<pre>';
    
    
    var_dump($mohanlalMovies);
    
    
    echo '</pre>';

    http://php.flashwebhost.com/tom/array_add_1.php

    Code:
    <?php 
    
    
    $mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova'); 
    
    
    echo '<pre>';
    
    
    print_r($mohanlalMovies);
    
    
    echo '</pre>';
    
    
    echo 'I am going to add 2 more films to $mohanlalMovies array';
    
    
    $mohanlalMovies[] = 'Christian Brothers';
    $mohanlalMovies[] = 'China Town';
    
    
    
    
    echo '<pre>';
    
    
    print_r($mohanlalMovies);
    
    
    echo '</pre>';

    http://php.flashwebhost.com/tom/array_add_2.php

    Code:
    <?php
    
    
    $mohanlalMovies = array('Mr. Fraud', 'Drishyam', 'Geethanjali', 'Red Wine', 'Ladies and Gentleman', 'Lokpal', 'Karmayodha', 'Run Baby Run', 'Spirit', 'Grandmaster', 'Casanova');
    
    
    foreach($mohanlalMovies as $movies) {
    
    
    echo $movies;
    
    
    echo '<br>';
    
    
    }
    
    
    echo '<p>I am going to add 4 more movies to $mohanlalMovies array</p>';
    
    
    $mohanlalMovies[] = 'Christian Brothers';
    $mohanlalMovies[] = 'China Town';
    $mohanlalMovies[] = 'Shikkar';
    $mohanlalMovies[] = 'Bhramaram';
    
    
    foreach($mohanlalMovies as $movies) {
    
    
    echo $movies;
    
    
    echo '<br>';
    
    
    }

  7. #37
    Join Date
    Sep 2003
    Posts
    3,040

    Default

    In array_add_2.php, variable $movies store one film name, so use singular name $movie.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

  8. #38
    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(9876543210);

    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.

  9. #39
    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>';
    }

  10. #40
    Join Date
    May 2014
    Posts
    21

    Default

    php.flashwebhost.com/austin/array.php

    Code:
    <?php
    $ar= array('christmas','holy','onam','easter');
    $ar[1] = 'whale';
    $ar[]= 'kills';
    foreach($ar as $a ){
    echo $a. '<br>';
    }

Page 4 of 5 FirstFirst ... 2345 LastLast

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
  •