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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:59:56+00:00 2026-05-28T01:59:56+00:00

I have an array $all_orders which contains arrays, the $temp_array contains every iteration after

  • 0

I have an array $all_orders which contains arrays, the $temp_array contains every iteration after explode a string composed of 8 words, and $handle is composed of 3 lines in the file:

while(!feof($handle))
{
  $order=fgets($handle);
  $temp_array=explode(",",$order);
  array_push($all_orders,$temp_array);
}

Now when i try to count the $all_orders array elements (which is supposed to be 3), i get simply 8:

echo count($all_orders);// display 8

why didn’t i get 3 ?

EDIT:

Here is the result i got when trying to print to content of the array:

Array
(
    [0] => Array
        (
            [0] =>

        )

    [1] => Array
        (
            [0] =>

        )

    [2] => Array
        (
            [0] => 1
            [1] => 1
            [2] => chaine.com
            [3] => chaine
            [4] => chaine
            [5] => chaine
            [6] => chaine
            [7] => chaine

        )

    [3] => Array
        (
            [0] =>

        )

    [4] => Array
        (
            [0] => 2
            [1] => 1
            [2] => chaine@fudd.com
            [3] => chaine.
            [4] => chaine
            [5] => chaine
            [6] => chaine
            [7] => chaine

        )

    [5] => Array
        (
            [0] =>

        )

    [6] => Array
        (
            [0] => 3
            [1] => 2
            [2] => chaine@bunny.com
            [3] => chaine.
            [4] => chaine
            [5] => chaine
            [6] => chaine
            [7] => chaine

        )

    [7] => Array
        (
            [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-05-28T01:59:56+00:00Added an answer on May 28, 2026 at 1:59 am

    You have one of two problems:

    • Your file has some blanks lines in it
    • PHP is getting confused by the style of the line endings (such as \r\n on a platform that just uses \n)

    Regardless of what the problem actually is, this should fix it:

    while(!feof($handle)) {
      // Evaluating the trimmed line as a bool will effectively skip blank lines
      if (!trim($order = fgets($handle))) continue;
      $all_orders[] = explode(',', $order);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which i pass into my views and contains all the
I have an (access) database table which contains data I would like to populate
I have an array List<SomeObject> which contain ascending order of dates (and some more
I have 3 files: DB.class.php - which handles all the databases. Site.class.php - contains
I have used mongodb 1.8.1. In which I have collection which contains more than
I have an array of values all well within the range 0 - 63,
I have an array of array like below with all numeric values. I want
I have an array of strings: @array I want to concatenate all strings beginning
I have an array of threads, and I want to Join them all with
You have: val array = new Array[Array[Cell]](height, width) How do you initialize all elements

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.