Solved

Array Pointer

Posted on 2004-09-18
2
187 Views
Last Modified: 2009-07-29
//from php.net
Remember that print_r() will move the array pointer to the end. Use reset() to bring it back to beginning.

I was wondering what it means by the array pointer being at the end?  why is this bad?


Thanks!,

Chilled
0
Comment
Question by:chilled2003
2 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 12090812
Hi chilled2003,

Sometimes, you'll have to loop through an array and need the array pointer at the beginning. A classic example is when you're using next() or current(), for example, take this:

$testArray = array("dog","cat","eagle");
echo current($testArray);   //echos "dog"
echo next($testArray);      //echos "eagle"
reset($testArray);
echo current($testArray);   //echos "dog" again


You get the gist.

Regards,
Zyloch
0
 

Author Comment

by:chilled2003
ID: 12090821
I see now.  Thanks! :D
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question