CodeIgniter Forums
Move array pointer? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Move array pointer? (/showthread.php?tid=64896)

Move array pointer? - iridion2015 - 04-08-2016

Hi guys

I need to move an array pointer from another method.

Here are my codes

class Language extends MY_Controller
   public $fruits = array();

   function __construct()
       $this->fruits = array('apple', 'orange', 'mango', 'banana', 'guyabano');

    //show current array pointer position/value
   public function idx()
       $position = current($this->fruits); // $mode = 'foot';
       echo 'Current index ===> '. $position .'<br>';
    //Move array pointer one step forward
   public function move_idx()

I have a  button called "Next".
When this button was pressed it will call move_idx() method to move the pointer one step forward.

The problemis when I tested this it did not work. 
The pointer did not move one step forward..

Would anyone like to help me?
What's the proper way to do this?

Thanks in advance.