⊗ppPmAFRv 171 of 447 menu

Reversing Arrays in PHP

array_flip array_reverse

Given an array:

<?php $arr = ['a' => 1, 'b' => 2, 'c' => 3]; ?>

Swap the keys and values in it.

Given an array:

<?php $arr = [1, 2, 3, 4, 5]; ?>

Make the following array from it:

<?php [5, 4, 3, 2, 1] ?>
byenru