Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • array_flip function php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 104
    Comment on it

    Welcome to Findnerd. We are going to discuss the array function named array_flip which is useful to exchange the keys and its associated values.Please have a look.

      <?php
        $patients_nfo = array('Deepak'=>23,'Dipti'=>24,'sonak'=>34);
        $flip_arr = array_flip($patients_info);
        print_r($flip_;arr);
        ?>
    
    result: array([23]=>'deepak',[24]=>'dipti',[34]=>'sonak');
    

    If you have same values in the array then last value will be added in key. Please have a look.

    <?php
    $patients_info = array('Deepak'=>23,'Dipti'=>23,'sonak'=>34);
    $flip_arr = array_flip($patients_info);
    print_r($flip_arr);
    ?>
    result: array([23]=>'dipti',[34]=>'sonak');
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: