UK [pr?v] US [pr?v]

[MEDICAL] PREVENTION

php prev() function syntax

Function: Point the internal pointer to the previous element in the array and output it.

Syntax: prev(array)

Parameters:

Parameter Description
arrayRequired. Specify the array to be operated on.

Note: If the array contains empty cells, or the value of the cell is 0, this function will also return FALSE when encountering these cells.

php prev() function example

<?php
$people = array("西門", "滅絕", "無忌");
$people2 = next($people); //指向下一個(gè)元素 滅絕
echo $people2;
echo "<br>";
$people3 = prev($people);//指向上一個(gè)元素 西門
echo $people3;
?>

Run instance?

Click the "Run instance" button to view the online instance

Output:

滅絕
西門


<?php
$arr = array("peter", "官人", "歐陽克");
$arr2 = next($arr); //指向下一個(gè)元素 官人
echo $arr2;
echo "<br>";
$arr3 = prev($arr);//指向上一個(gè)元素 peter
echo $arr3;
?>

Run Instance?

Click the "Run Instance" button to view the online instance

Output:

官人
peter