PREV(3) 1 PREV(3)prev - Rewind the internal array pointerSYNOPSIS
mixed prev (array &$array)
DESCRIPTION
Rewind the internal array pointer.
prev(3) behaves just like next(3), except it rewinds the internal array pointer one place instead of advancing it.
PARAMETERS
o $array
- The input array.
RETURN VALUES
Returns the array value in the previous place that's pointed to by the internal array pointer, or FALSE if there are no more elements.
EXAMPLES
Example #1
Example use of prev(3) and friends
<?php
$transport = array('foot', 'bike', 'car', 'plane');
$mode = current($transport); // $mode = 'foot';
$mode = next($transport); // $mode = 'bike';
$mode = next($transport); // $mode = 'car';
$mode = prev($transport); // $mode = 'bike';
$mode = end($transport); // $mode = 'plane';
?>
NOTES
Warning
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on
Booleans for more information. Use the === operator for testing the return value of this function.
Note
You won't be able to distinguish the beginning of an array from a boolean FALSE element. To properly traverse an array which may
contain FALSE elements, see the each(3) function.
SEE ALSO current(3), end(3), next(3), reset(3), each(3).
PHP Documentation Group PREV(3)
Check Out this Related Man Page
RESET(3) 1 RESET(3)reset - Set the internal pointer of an array to its first elementSYNOPSIS
mixed reset (array &$array)
DESCRIPTION reset(3) rewinds $array's internal pointer to the first element and returns the value of the first array element.
PARAMETERS
o $array
- The input array.
RETURN VALUES
Returns the value of the first array element, or FALSE if the array is empty.
EXAMPLES
Example #1
reset(3) example
<?php
$array = array('step one', 'step two', 'step three', 'step four');
// by default, the pointer is on the first element
echo current($array) . "<br />
"; // "step one"
// skip two steps
next($array);
next($array);
echo current($array) . "<br />
"; // "step three"
// reset pointer, start again on step one
reset($array);
echo current($array) . "<br />
"; // "step one"
?>
SEE ALSO current(3), each(3), end(3), next(3), prev(3).
PHP Documentation Group RESET(3)
hi all,
let say i have a pointer exit, and this exit will store some value. how can i store the value that the pointer points to into an array and then print them out from the array.
thanks in advance (2 Replies)
I want to do something like this:
Original file:
a car
the house
x tree
After running the TR command I want this:
a car
the house
tree
I've already tried almost all combinations of the TR command, begin of line, \ , etc etc and I can't do it.
Can anyone help? Or there is any other... (1 Reply)
Hi all
I would like to know if there is a way to return an array for a function.
As I know function can return all the contents in an array, I want to return an array type. (6 Replies)
Hi folks,
i know its totally diff topic on this community ... :-)
Are you interested in bike riding !!!
if yes , what is your fav bike ?
what bike are you having now at your home ?
what is your longest ride ?
I have a indian made 200cc bike .. most of the time, i... (2 Replies)
im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
I'm just curious about the amount of time it takes you to get to work in the morning and whether you drive a car, ride a bike, walk or take public transportation.
On a typical day I drive 10-15 minutes from my house to my work location followed by a 10 walk from the parking lot (car park to my... (12 Replies)
How can I assign a variable to an variable. IE $car=honda
One way I can do it is export $car=honda
or
let $car=2323
Is there any other ways to preform this task (3 Replies)
Without grep, I'd like to make a test condition so that any a word that does not have the successive letters car in it will be echoed. for example, bluecar will contain "car" so it will show up as a no
var=bluecar
$ echo $var|if ]; then echo "yes";fi
yes
this variable contains "car" so I... (5 Replies)