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 7769003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:03:45+00:00 2026-06-01T16:03:45+00:00

So I spent 2 hours trying to figure this out, minimizing the code as

  • 0

So I spent 2 hours trying to figure this out, minimizing the code as much as possible to isolate the problem, yet I can’t figure this out.

So I have this code:

$arr['key']['name'] = array("one", "two", "three");

$counter = 0;
do
{
    $cur = current($arr);

    $k = key($arr['key']['name']);
    next($arr['key']['name']);
}while($k !== null);

This is a never ending loop. For some reason, after going through all the $arr[‘key’][‘name’] values, key() instead of returning NULL, goes back to 0 again. Removing $cur = current($arr); however solves that problem. According to php manual, current() doesn’t affect the array pointer at all. Now I know that copying an array will reset its pointer but there’s no copying going on and if there was $k would constantly be zero instead of going from 0 to 2 and then resetting back to 0.

  • 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-06-01T16:03:48+00:00Added an answer on June 1, 2026 at 4:03 pm

    current() doesn’t move the array pointer for the array you use it on, but you’re using it on different arrays. It is resetting the pointer for the nested arrays.

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

Sidebar

Related Questions

I have now spent several hours trying to figure this out. I have this
I just spent the last 3 hours trying to figure out this error. I
Alright, I've spent about 5 hours trying to figure this out. Absolutely none of
I've spent a couple hours now trying to figure this out, but I just
I have an issue that I've spent hours trying to figure out, but since
spent a few hours trying to figure this out, but cannot for the life
I've spent quite a few hours researching and trying to figure out why I'm
I have a problem with php header redirect. I already spent hours trying to
Is there another way to do this? Just spent 2 hours trying to figure
Okay, I just spent the last four hours trying to figure out why my

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.