Questions tagged [array-flip]

A PHP function that exchanges all keys with their associated values in an array.

PHP array_flip() function exchanges all keys with their associated values in an array and returns an array in flip order. manual

Example

$input = array("oranges", "apples", "pears");
$flipped = array_flip($input);
print_r($flipped);

Result

Array
(
    [oranges] => 0
    [apples] => 1
    [pears] => 2
)
17 questions
-1
votes
4 answers

array_flip with an array in the value

Simple one (but not solved yet): this is my array [ [ "role" => "admin", "name" => [ "Felipy", "Ivan", ], ], [ "role" => "user", "name" => [ "Michel", "Paul", "Tay", ], ] And I would love to see this…
Gabriel Caruso
  • 789
  • 1
  • 7
  • 17
-4
votes
3 answers

Error "expecting array" with PHP array_flip() function

I recently updated the server on which I work. I have got an error: "Warning: array_flip() expects parameter 1 to be array, null given in..." Does someone know how to fix it? Here is a part of PHP code: function redirectWrongDep($url) { $deps…
Pureandfast
  • 29
  • 4
  • 7
1
2