Searching for "array_flip"

Q:

Why we use array_flip

Answer

array_flip exchange the keys with their associated values in array ie. Keys becomes values and values becomes keys.

<?php
$arrayName    = array("course1"=>"php","course2"=>"html");
$new_array    = array_flip($arrayName);
print_r($new_array);
?>

OUTPUT :

Array
(
[php]     => course1
[html]    => course2
)

Report Error

View answer Workspace Report Error Discuss

Subject: PHP