Php array Getting Started Tutorial on array pointer operations
This article introduces the content related to array pointers in php arrays. For more information, see. In php, functions involving array pointers include reset, prev, end, next, current, and each. Example 1: next and prev
"; Echo prev ($ speed); // outputs the array value echo in the previous position" "; Echo reset ($ speed); // reset the array pointer to point the pointer to the starting position echo" "; Echo end ($ speed); // output the array value at the last position echo" "; // By bbs.it-home.org?> Result: 02202000220 Example 2: each function pointer operation
"; Echo" 0 speed is ". current (each ($ speed ))." "; Echo" 1 speed is ". current (each ($ speed ))." "; Echo" 2 speed is ". current (each ($ speed ))." "; Echo" 3 speed is ". current (each ($ speed ))." "; Echo" the speed of 4 blocks is ". current (each ($ speed ))." "; Echo" 5 speed is ". current (each ($ speed ))." "; Echo" use the each function to move the array pointer and traverse the array. "; Reset ($ speed); // Here, the array pointer is directed to the first while (list ($ key, $ value) = each ($ speed) {echo $ key. "=> ". $ value." ";}?> Running result: the speed at which the each pointer moves down 0 blocks is 01 block speed is 402 block speed is 803 block speed is 1204 block speed is 1605 block speed is 200 Block speed is use each function to implement array pointer movement, array traversal 0 => 01 => 402 => 803 => 1204 => 1605 => 200 |