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

  • SEARCH
  • Home
  • 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 7609127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:05:46+00:00 2026-05-31T01:05:46+00:00

Imagine a simple, but large array with keys 0 to 100000. When doing a

  • 0

Imagine a simple, but large array with keys 0 to 100000.

When doing a foreach loop of this array, is it possible to ‘seek’ ahead without doing something like:

foreach($array as $key=>$value){
    if($key<10000){
         continue;
    }
}

We do this kind of operation once in a while thru our codebase. It seams like a bit of a waste of ticks to go thru each of the keys until key is greater then 10000.

Is this possible in php 5.4?

Thanks.

  • 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-31T01:05:47+00:00Added an answer on May 31, 2026 at 1:05 am

    it was possible even in PHP 2.0FI or ALTAIR BASIC

    for($i=10000;$i < count($array);$i++){
    }
    

    No doubt some nitpickers will come to tell that doing count($array) 90000 times is a waste of ticks too.
    However, to get a real performance gain one have to avoid lengthy loops at all.

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

Sidebar

Related Questions

I've never learnt JavaScript, but I imagine this is quite a simple problem. Just
I imagine this must have a simple answer, but I am struggling: I want
I imagine this is simple - but I can't find the right combination of
I'm only just learning javascript so I imagine this is relatively simple but it's
Imagine a simple case like this: class Book has_many :chapters end Let's say in
Imagine this simple form <form action=<?php echo $_SERVER['REQUEST_URI']; ?> method=post> <fieldset> <legend>Contact Me</legend> <label
I imagine this has a rather simple answer <% for user in @users %>
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I imaging this is going to be a simple task but I can't find
Imagine you have a large array of floating point numbers, of all kinds of

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.