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
    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];

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

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

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

    Default

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

    Code:
    <?php
    
    $subjects = array('Malayalam', 'Hindi', 'Maths', 'scinece');
    
    echo 'My Favourite Subjects are ' . $subjects[1] . 'and ' . $subjects[4];
    
    echo '<pre>';
    print_r($subjects);
    echo '</pre>';

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

    Default

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

    Code:
    <?php
    
    $mystudents = array('Neena' , 'Meera' , 'Leena' , 'Zeena' );
    foreach ($mystudents as $mystudents) {
    echo $mystudents;
    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
  •