PHP Array flip() FunctionLast Updated : 17 Mar 2025 This function is used to flip the array with the keys and values. It takes one parameter that is an array. The returned array will contain the flipped elements. The values will be the keys, and the keys will be the values. This function was introduced in PHP 4.0. SyntaxParameter
Return TypeIt returns the flipped array on success. Note:The values of the array need to be valid keys, i.e., they need to be either integer or string.EXAMPLE 1Output: Array ( [1] => a [2] => b [3] => c [4] => d [5] => e ) EXAMPLE 2Output: Array ( [oranges] => 0 [apples] => 1 [banana] => 2 ) EXAMPLE 3Output: Array ( [jaya] => amitabh [nargis] => raj [katrina] => akshay [juhi] => aamir ) EXAMPLE 4Output: Array ( [brown] => a [green] => b [yellow] => c ) Next TopicPhp-in-array-function |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India