ExpertRefresh

Array / Pointer  

Related Pages

Basics
Operations
Create
Key-value
Search
Modify
Pointer
Sort
Stacks
Randomize
Storage


0.0% 100%
 
 
0 pages 298 questions
1) Advance the pointer in the array




2) How do you get current key from an array?






key, current, next, reset <?php $arr = array('a' => 1, 'b' => 2, 'c' => 3); reset($arr); while (key($arr) !== NULL) { echo key($arr) . current($arr) . " "; next($arr); } // Output: a1 b2 c3 end, prev <?php // You could start your iteration from the last element $arr = array('a' => 1, 'b' => 2, 'c' => 3); end($arr); while (key($arr) !== NULL) { echo key($arr) . current($arr) . " "; prev($arr); } // Output: c3 b2 a1


References