Three Type of PHP Arrays tutorial in Khmer

Hello everyone, today me show you about PHP arrays. We learn how use different arrays in PHP. There are three types of arrays in PHP.
  • Index Arrays
  • Associative Arrays
  • Multidimensional Array
  • .

    If you want to learn more, please check our: [PHP Tutorial in Khmer Playlist].

    1. Indexed Arrays in PHP

    Indexed arrays is a simple array and use number as index to access thestore value.
    For example:
    
        <?php
    
        $fruits = array("mango", "banana", "watermelon");
    
        echo $fruits[0]; // output mango
    
        ?>
    
    Watch more detail in video about Index Arrays in PHP speak khmer

    2. Associative Arrays in PHP

    Associative arrays is bit different from Index array. It is a key - value pair array and access it value by key.
    See example below:
    
        <?php
        
        $person = array("name" => "sok", "gender" => "male", "age" => 30);
    
        echo $person["name"]; // output sok
    
        echo $person["gender"];
    
        ?>
    
    Watch more detail in video about Associative Arrays in PHP tutorial khmer

    3. Multidimensional Arrays

    Anyway, multidimensional arrays is more complex. It is the array in another array - called nested array. It can have index array or associative array mix together.
    For example:
    
        <?php
        
        $contacts = array(
    
            array("name" => "Raksmey", "phone" => "12345"),
            
            array("name" => "Sophal", "phone" => "67890")
        );
        
        echo $contacts[0]["name"]; // output Raksmey
    
        ?>
    
    Watch more detail in video about Multidimensional Arrays in PHP khmer tutorial

    How to Creating and Using Functions in PHP Tutorial Khmer :Back 👈 👉 Next:More lesson Comming Soon

    I hope you enjoy learning PHP with me and don't forget to share this post to your friends. Keep learning and sharing.

    Caring is sharing!!! - happy coding

    Free Khmer Ebook Download (PDF): Database | Microsoft Access | Python Programming
    Previous Post Next Post