Wednesday, 24 September 2014

array_flip in PHP

array_flip() function give one array argument and change it so that keys are now the values and contrariwise.

Syntax:
array_flip(array)

Parameter Description:
array : Required. Define an array.

Example:

<?php 
$days = array( 0=>"Sunday", 1=>"Monday", 2=>"Tuesday" );
print_r( array_flip($days) );
?>

O/P:


Array (
           [Sunday] => 0 
           [Monday] => 1
           [Tuesday] => 2 
        )

0 comments:

Post a Comment