Results 1 to 7 of 7

Thread: personal web page

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_diff_ukey() Function

    <?php
    function myfunction($v1,$v2)
    {
    if ($v1===$v2)
    {
    return 0;
    }
    if ($v1>$v2)
    {
    return 1;
    }
    else
    {
    return -1;
    }
    }
    $a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
    $a2=array(3=>"Rat",1=>"Bird",5=>"Monkey");
    print_r(array_diff_ukey($a1,$a2,"myfunction"));
    ?>

  2. #2
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_change_key_case() Function

    Example 1

    <?php
    $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
    print_r(array_change_key_case($a,CASE_UPPER));
    ?>

    Example 2

    <?php
    $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","B"=>" Bird");
    print_r(array_change_key_case($a,CASE_UPPER));
    ?>

  3. #3
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_chunk() Function

    <?php
    $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>" Cow");
    print_r(array_chunk($a,2));
    ?>

    Array (
    [0] => Array ( [0] => Cat [1] => Dog )
    [1] => Array ( [0] => Horse [1] => Cow )
    )

    Example 2

    <?php
    $a=array("a"=>"Cat","b"=>"Dog","c"=>"Horse","d"=>" Cow");
    print_r(array_chunk($a,2,true));
    ?>

  4. #4
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_combine() Function

    Example 1

    <?php
    $a1=array("a","b","c","d");
    $a2=array("Cat","Dog","Horse","Cow");
    print_r(array_combine($a1,$a2));
    ?>

    Example 2

    The output of the code above will be:

    Array ( [a] => Cat [b] => Dog [c] => Horse [d] => Cow )

  5. #5
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_pop() Function


    <?php
    $a=array("Dog","Cat","Horse");
    array_pop($a);
    print_r($a);
    ?>
    The output of the code above will be:

    Array ( [0] => Dog [1] => Cat )

  6. #6
    Join Date
    Oct 2010
    Location
    Arthunkal
    Posts
    17

    Default personal web page

    PHP array_slice() Function

    Example 1
    <?php
    $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");
    print_r(array_slice($a,1,2));
    ?>
    Example 2
    <?php
    $a=array(0=>"Dog",1=>"Cat",2=>"Horse",3=>"Bird");
    print_r(array_slice($a,-2,1));
    ?>

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
  •