Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6833403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:58:26+00:00 2026-05-26T22:58:26+00:00

I created a simple test case that replicates an issue I’m having. I’m walking

  • 0

I created a simple test case that replicates an issue I’m having.

I’m walking through a two dimensional array using the next() and current() functions, and am wanting to setup the array pointer to a specific location. So, given a 2D array with a variable name of $food with the following array structure:

array
  0 => <-- POINTER LOCATION
    array
      0 => string 'apple' <-- POINTER LOCATION
      1 => string 'orange'
  1 => 
    array
      0 => string 'onion'
      1 => string 'carrot'

… And the following code snippet:

// move the inner array's pointer once
$should_be_orange = next(current($food));

// now check that inner array's value
$should_still_be_orange = current(current($food));

… Why is the value of $should_be_orange “orange” but the value of $should_still_be_orange “apple”? Is this because the current() function returns a copy of the inner array, who’s pointer gets iterated, and then destroyed (leaving the original array untouched)? Or am I simply doing something wrong that I’m not catching?

At the root of the question, how do you move the inner array’s pointer given that you don’t know the outer array’s key (and must use the current() function to obtain the outer array’s pointer location)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:58:27+00:00Added an answer on May 26, 2026 at 10:58 pm

    Actually current() returns an element from the array. In your case, this element is also an array, and that’s why next() is working at all in your code. Your next() do not work on the $food array, but on copy of $food[0], returned by current()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL Server 2008 Enterprise. I have created a very simple test
I created two very simple Heroku apps to test out the service, but it's
As a test case for an issue I'm having with application deployment, I built
I've created a simple test case exhibiting a strange behavior I've noticed in a
I created a simple test page on my website www.xaisoft.com and it had no
I created a simple test with SendKeys, and tried both SendWait and Send. Private
I have created a simple test form with FormBorderStyle = FixedToolWindow by default and
Could someone help me on this, I have created simple web services using axis2
I couldn't get this to work in Silverlight, so I created two test projects.
I am attempting to test simple UI with the following test case, The main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.