Page 1 of 2 12 LastLast
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
    Nov 2009
    Posts
    76,596

    Default

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

    Code:
    <?php
    $age=array('Susan', 'Jane','Anne');
    echo 'My Best friends are ';
    
    // lets print
    
    echo $name[0];
    echo '<br>';
    echo $name[1];
    echo '<br>';
    echo $name[2];
    Last edited by sherlyk; 05-15-2014 at 07:33 AM.

  2. #2
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default

    PHP Code:
    <?php
    $mobile 
    = array('Nokia' 'Samsung''Sony' 'LG''Micro Max') ;
    echo 
    $mobile[0];echo '<br>';echo $mobile[1];echo '<br>';echo $mobile[2];echo '<br>';echo $mobile[3];echo '<br>';echo $mobile[4];
    http://php.flashwebhost.com/sibichan/Day-5/mobile.php

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

    Default

    Quote Originally Posted by sibichan1 View Post
    PHP Code:
    <?php
    $mobile 
    = array('Nokia' 'Samsung''Sony' 'LG''Micro Max') ;
    echo 
    $mobile[0];echo '<br>';echo $mobile[1];echo '<br>';echo $mobile[2];echo '<br>';echo $mobile[3];echo '<br>';echo $mobile[4];
    http://php.flashwebhost.com/sibichan/Day-5/mobile.php
    Good script. Better to have one PHP statement per time, that is a new line after each semicolon.
    Become PHP Expert in 30 days
    FreeMarriage.com - Free Online Matrimonial
    FlashWebHost.com - Professional Web Hosting, Designing.

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

    Default

    I didn't get answer when click on that link, why ?

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

    Code:
    <?php
    
    // create array
    
    $birds = array('crow', 'crane', 'eagle', 'parrot', 'hen', 'cock', 'sparrow', 'koel', 'peacock', 'myna');
    
    // lets print
    
    echo $birds[1];
    echo '<br>';
    echo $birds[2];
    echo '<br>';
    echo $birds[4];
    echo '<br>';
    echo $birds[8];

  5. #5
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default

    Quote Originally Posted by sherlyk View Post
    I didn't get answer when click on that link, why ?

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

    Code:
    <?php
    
    // create array
    
    $birds = array('crow', 'crane', 'eagle', 'parrot', 'hen', 'cock', 'sparrow', 'koel', 'peacock', 'myna');
    
    // lets print
    
    echo $birds[1];
    echo '<br>';
    echo $birds[2];
    echo '<br>';
    echo $birds[4];
    echo '<br>';
    echo $birds[8];


    I just copy/paste/uploaded your script

    http://php.flashwebhost.com/sibichan/Day-5/birds1.php

    Its working.

  6. #6
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default print_r() and var_dump() examples

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

    PHP Code:

    <?php 


    $constituentCountry 
    = array(' Denmark ' 'France ' ' Netherlands ' ' New Zealand ' ' United Kingdom ');


    echo 
    '<h1>print_r() function example</h1>';


    echo 
    '<pre>';


    print_r ($constituentCountry);


    echo 
    '<h1>var_dump() function example</h1>';


    var_dump ($constituentCountry);


    echo 
    '</pre>';

  7. #7
    Join Date
    Nov 2009
    Location
    kerala
    Posts
    19,076

    Default array_count exmple

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

    PHP Code:

    <?php 
    $family 
    = array('Father','Mother','Brother' 'Sister');
    $numberOfFamily count($family);
    echo 
    ' I have ' $numberOfFamily ' members in my family .';
    echo 
    '<br>';
    echo 
    $family[0];
    echo 
    '<br>';
    echo 
    $family[1];
    echo 
    '<br>';
    echo 
    $family[2];
    echo 
    '<br>';
    echo 
    $family[3];

  8. #8
    Join Date
    Apr 2005
    Posts
    46,704

    Default

    http://php.flashwebhost.com/mini/array.php


    Code:
    <?php
    
    
    $animals = array('lion', 'dog', 'cat', 'horse', 'rabit', 'tiger', 'rabit', 'camel', 'deer', 'fox', 'squirrel');
    
    echo $animals[0];
    echo '<br>';
    echo $animals[2];
    echo '<br>';
    echo $animals[3];
    echo '<br>';
    echo $animals[5];
    echo '<br>';
    echo $animals[10];

  9. #9
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/sports.php


    Code:
    
    <?php
    
    
    $sports = array('FootBall', 'Cricket', 'Hockey', 'basketball', 'Golf', 'rugby', 'Baseball');
    
    
    echo $sports[0];
    echo '<br>';
    echo $sports[1];
    echo '<br>';
    echo $sports[6];
    echo '<br>';
    echo $sports[2];
    echo '<br>';

  10. #10
    Join Date
    Nov 2004
    Location
    India
    Posts
    65

    Default

    http://php.flashwebhost.com/stefin/trees.php

    Code:
    <?php
    $garden = array('mango tree', 'apple tree', 'cherry tree', 'Jackfruit tree', 'neem tree', 'mulberry tree', 'coconut tree');
    
    
    echo '<pre>';
    print_r($garden);
    echo '</pre>';
    echo '<p>The Gardener Is Going To Plant Four More Trees In His $garden array</p>';
    
    
    $garden[] = 'bamboo tree';
    $garden[] = 'rubber tree';
    $garden[] = 'teak tree';
    $garden[] = 'rose wood';
    
    
    echo '<pre>';
    print_r($garden);
    echo '</pre>';

Page 1 of 2 12 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
  •