1--TEST--
2Test prev() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : mixed prev(array $array_arg)
6 * Description: Move array argument's internal pointer to the previous element and return it
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Test basic functionality of prev()
12 */
13
14echo "*** Testing prev() : basic functionality ***\n";
15
16$array = array('zero', 'one', 'two');
17end($array);
18echo key($array) . " => " . current($array) . "\n";
19var_dump(prev($array));
20
21echo key($array) . " => " . current($array) . "\n";
22var_dump(prev($array));
23
24echo key($array) . " => " . current($array) . "\n";
25var_dump(prev($array));
26
27echo "\n*** Testing an array with differing values/keys ***\n";
28$array2 = array('one', 2 => "help", 3, false, 'stringkey2' => 'val2', 'stringkey1' => 'val1');
29end($array2);
30$length = count($array2);
31for ($i = $length; $i > 0; $i--) {
32    var_dump(prev($array2));
33}
34
35?>
36===DONE===
37--EXPECTF--
38*** Testing prev() : basic functionality ***
392 => two
40string(3) "one"
411 => one
42string(4) "zero"
430 => zero
44bool(false)
45
46*** Testing an array with differing values/keys ***
47string(4) "val2"
48bool(false)
49int(3)
50string(4) "help"
51string(3) "one"
52bool(false)
53===DONE===
54