• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move array pointer?

#1
Hi guys

I need to move an array pointer from another method.

Here are my codes

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

   
   function __construct()
   {
       parent::__construct();
       $this->load->model('qa_mdl');
       
       $this->fruits = array('apple', 'orange', 'mango', 'banana', 'guyabano');
       
   }

   
    //show current array pointer position/value
   public function idx()
   {
       $this->load->helper('array');
       
       showArray($this->fruits);
       
       $position = current($this->fruits); // $mode = 'foot';
       echo 'Current index ===> '. $position .'<br>';
   }  
   
    
    //Move array pointer one step forward
   public function move_idx()
   {
       next($this->fruits);
       redirect('language/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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.