Solved

Array Pointer

Posted on 2004-09-18
2
198 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…

632 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