Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Array Pointer

Posted on 2004-09-18
2
Medium Priority
?
199 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 200 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
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…
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 count occurrences of each item in an array.

721 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