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
    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.

  2. #2
    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];

  3. #3
    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.

  4. #4
    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>';

  5. #5
    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];

  6. #6
    Join Date
    Sep 2003
    Location
    india
    Posts
    11,527

    Default

    http://php.flashwebhost.com/annie/array_raw.php

    Code:
    <?php
    
    $flowers = array('Jasmine','Rose','Orkid', 'Lotus');
    
    echo 'My Favourit Flowers are ' . $flowers[1] . ' and ' . $flowers[3]; 
    
    echo '<pre>';
    print_r($flowers);
    echo '</pre>';


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

    Code:
    <?php
    
    $states = array('Alappuzha', 'Ernakulam', 'Thiruvanthapuram', 'Kollam', 'Palakkad');
    
    $numberOfStates = count($states);
    echo '<pre>';
    print_r($states);
    
    echo '<p> I am going to add 2 more states to $states array. </p>';
    
    $states[] = 'Kottayam';
    $states[] = 'Kannur';
    
    echo '<pre>';
    print_r ($states);
    echo '</pre>';

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

    Default Foreach Examples

    http://php.flashwebhost.com/sibichan...ch-example.php

    PHP Code:
    <?php
    $vechicles
    = array ('Bus' 'Car' 'Van' 'Auto');
    foreach (
    $vechicles as $vechicle) {
    echo 
    $vechicle;
    echo 
    '<br>';
    }
    Another Example for foreach

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

    PHP Code:


    <?php
    $networkingSites 
    = array('Facebook' 'Twitter' 'Pinterest' 'Delicious' );
    foreach (
    $networkingSites as $networkingSite) {
    echo 
    $networkingSite;
    echo 
    '<br>';
    }
    Last edited by Vahaa11; 05-14-2014 at 07:25 AM.

  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 2009
    Location
    kerala
    Posts
    19,076

    Default Array add example

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

    PHP Code:

    <?php $hostingPackage = array (' Small '' Medium ' ' Large ') ;
    echo 
    '<pre>';

    print_r($hostingPackage);

    echo 
    '</pre>';

    $hostingPackage [] = 'Premium';$hostingPackage [] = 'Starandard';

    echo 
    '<pre>';

    print_r($hostingPackage);echo '</pre>';
    Another example

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


    PHP Code:
    <?php 
    $companyNames 
    = array('BizHat''FlashWebHost''HostOnNet');
    echo 
    '<pre>';

    print_r($companyNames);

    echo 
    '</pre>';
    echo 
    'Iam going to add 2 more Company Names';
    echo 
    '<br>';
    $companyNames[] = 'Buyscripts';
    $companyNames[]= 'FreeMarriage';
    echo 
    '<pre>';

    print_r($companyNames);

    echo 
    '</pre>';
    Last edited by Vahaa11; 05-14-2014 at 08:59 AM.

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

    Default

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

    Code:
    <?php
    
    $states = array('Kerala' , 'Tamil Nadu' , 'Karnataka' , 'Rajastan' , 'Orissa' );
    
    $numberOfStates = count($states);
    echo '<pre>';
    print_r($states);
    
    echo '<p> I am going to add 2 more states to $states array. </p>';
    
    $states[] = 'Kerala';
    $states[] = 'Tamil Nadu';
    
    echo '<pre>';
    print_r ($states);
    echo '</pre>';
    Last edited by sherlyk; 05-14-2014 at 09:33 AM.

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
  •