Solved

Array Pointer

Posted on 2004-09-18
2
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

751 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