2 /* Prototype : array array_reverse(array $array [, bool $preserve_keys])
3 * Description: Return input as a new array with the order of the entries reversed
4 * Source code: ext/standard/array.c
8 * testing the functionality of array_reverse() by giving unexpected values for $preserve_keys argument
14 public function __toString(){
15 return "Class A object";
18 <<__EntryPoint
>> function main(): void
{
19 echo "*** Testing array_reverse() : usage variations ***\n";
21 // Initialise the array
22 $array = array("a" => "green", "red", "blue", "red", "orange", "pink");
24 //get an unset variable
28 //get a resource variable
29 $fp = fopen(__FILE__
, "r");
31 //array of values to iterate over
32 $preserve_keys = array (
52 array('color' => 'red', 'item' => 'pen'),
83 // loop through each element of the array $preserve_keys to check the behavior of array_reverse()
85 foreach($preserve_keys as $preserve_key) {
86 echo "-- Iteration $iterator --\n";
87 try { var_dump( array_reverse($array, $preserve_key) ); } catch (Exception
$e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__
.' on line '.__LINE__
."\n"; }
91 // close the file resouce used