get current array position pointer while doing foreach $object->result_array()
Hi,
consider this, a case.
foreach($object->result_array() as $rs)
{
//how do i display the current array element index that is the iteration index.
//i want to call a function when the iterator is in the last-1 position.
// and more specifically i want to use it in this place and not any other for(;;) loops.
// and even it is an example with other loops then that is fine.
}
There should be an option or by using current() function.
I had tried but still i have to do some analysis…
Instead of debugging and tracing the array elements i am posting this thread.
and above all is it possible to do it with a for loop?
Add
=> $keylike this to get key as well:Yes like this: