array_flip( ) exchanges all the keys in that array with their matching values : array_flip « Data Structure « PHP






array_flip( ) exchanges all the keys in that array with their matching values

 
<?
    $capitalcities['England'] = 'London';
    $capitalcities['Scotland'] = 'Edinburgh';
    $capitalcities['Wales'] = 'Cardiff';
    $flippedcities = array_flip($capitalcities);
    var_dump($flippedcities);
?>
  
  








Related examples in the same category

1.Using array_flip() to return a string back to its original value
2.array_flip demo
3.array_flip() example
4.array_flip() function exchanges all key and element values for the array.