(PHP 4, PHP 5, PHP 7, PHP 8)
array_reverse — Devuelve un array con los elementos en orden inverso
Toma un valor array
y devuelve un nuevo array con
el orden de los elementos invertido.
array
El array de entrada.
preserve_keys
Si se establece en true
las claves numéricas se conservarán.
Las claves no numéricas no se ven afectadas por este ajuste y se conservarán siempre.
Devuelve el array en orden inverso.
Ejemplo #1 Ejemplo de array_reverse()
<?php
$input = array("php", 4.0, array("verde", "rojo"));
$reversed = array_reverse($input);
$preserved = array_reverse($input, true);
print_r($input);
print_r($reversed);
print_r($preserved);
?>
El resultado del ejemplo sería:
Array ( [0] => php [1] => 4 [2] => Array ( [0] => verde [1] => rojo ) ) Array ( [0] => Array ( [0] => verde [1] => rojo ) [1] => 4 [2] => php ) Array ( [2] => Array ( [0] => verde [1] => rojo ) [1] => 4 [0] => php )
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant