php prev() function
Translation results:
UK [prɪv] US [prɪv]
[MEDICAL] PREVENTION
php prev() functionsyntax
Function: Point the internal pointer to the previous element in the array and output it.
Syntax: prev(array)
Parameters:
Parameter | Description |
array | Required. 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() functionexample
<?php $people = array("西门", "灭绝", "无忌"); $people2 = next($people); //指向下一个元素 灭绝 echo $people2; echo "<br>"; $people3 = prev($people);//指向上一个元素 西门 echo $people3; ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
灭绝 西门
<?php $arr = array("peter", "官人", "欧阳克"); $arr2 = next($arr); //指向下一个元素 官人 echo $arr2; echo "<br>"; $arr3 = prev($arr);//指向上一个元素 peter echo $arr3; ?>
Run Instance»
Click the "Run Instance" button to view the online instance
Output:
官人 peter