MemoryRefresh!

Array / Pointer   Pointer



Questions Answers 0%

Pages   0 from 91
Questions   0 from 142

Reset


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

Related Pages

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


0% 100%
 
 
0 pages 91 pages
1) How do you get current key from an array?




2) Advance the pointer in the 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









Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References