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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:34:36+00:00 2026-05-18T20:34:36+00:00

EDIT3: It seems that the problem occurs on my localhost XAMPP PHP 5.3 setup,

  • 0

EDIT3: It seems that the problem occurs on my localhost XAMPP PHP 5.3 setup, not on any of the remote servers running php 5.2 that I’ve tested. Still unclear if its php or xampp (or maybe the combination) that causes the error /EDIT3

I have an xml with about 12000 names to add to an array.
The xml structure looks like this:

<smdusersync datetime="2010-12-13 13:51:16">
  <userstoadd>
    <User fnamn="Adam" enamn="Svensson" email="adam@darkeye.se" password="3906" />
    <User fnamn="Brooke" enamn="Jarnbjer" email="brooke@gmail.com" password="2729" />
    <User fnamn="Caesar" enamn="Carlsson" email="caesar@comhem.se" password="1668" />
   <!-- about 12000 other users -->
  </userstoadd>
  <userstoremove>
  </userstoremove>
</smdusersync>

EDIT2: I’ve tried with other xml examples, including programmatically generated with no attbutes etc, and that doesn’t matter – still the same problem described below… /EDIT2

When running a simple foreach loop on the xml userstoadd child, strange things start to
happen when I push objects to an array.

(Please note that the example below has the code that causes the error – it’s not a useful example in any way…)

Running a simple foreach loop (here just pushing a testcounter to the array) works as expected:

    $user_xml = simplexml_load_file('users.xml');
    $xml_count = $user_xml->userstoadd->children()->count();
    $users_arr = array();
    $test_count = 0;
    foreach ($user_xml->userstoadd->children() as $user) {

        array_push($users_arr, $test_count); // << Works as expected!
        $test_count++;
    }
    echo $xml_count, '/', $test_count; 

The $xml_count and $test_count always have the same value.

When I do the same, except for that I push a simple object to the array, everything works fine if the number of xml users <= 9940:

    $user_xml = simplexml_load_file('users.xml');
    $xml_count = $user_xml->userstoadd->children()->count();
    $users_arr = array();
    $test_count = 0;
    foreach ($user_xml->userstoadd->children() as $user) {
        $dummy_object = new StdClass();  // << Empty dummy object
        array_push($users_arr, $dummy_object); // << CAUSES ERROR if more than 9940 items...!
        $test_count++;
    }
    echo $xml_count, '/', $test_count; // << SHOULD BE THE SAME!

When having 9940 xml user items, the output is as expected 9940/9940.
BUT when having 9941 xml user items, the output is 9941/19881!
And when having 9942 xml user items, the output is 9942/19882!

Suddenly almost 10000 difference! And the content of the user items doesn’t seem to matter… I’ve copied and moved xml user items with the same result…

EDIT: When more than 9940 items, it suddeny doubles so that 9941 items give (9940 x 2) + 1 = 19881.
No difference when using one single xml user item 12000 times. /EDIT

Any idea what’s going on here?

  • 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-18T20:34:37+00:00Added an answer on May 18, 2026 at 8:34 pm

    The following insanity solves the problem for me:

    You might want to comment out the test(50000); line.

    <?php
    
    test(9996); // works                         (echoes 9996/9996/9996)
    test(9997); // BREAKS on my XAMPP php 5.3.1! (echoes 9997/19993/19993)
    test(50000); // test with larger number
    
    function test($items_to_create) {
        $xml_str = '<root>' . chr(13);
        for($i=0; $i<$items_to_create; $i++) {
            $xml_str .= '<item attr="t' . $i . '"/>' . chr(13);
        }
        $xml_str .= '</root>';
    
        $xml = new SimpleXMLElement($xml_str);
    
        $xml_children = $xml->children();
        $xml_count = $xml_children->count();
        $arr = array();
        $test_count = 0;
    
        /*
        foreach ($xml->children() as $user) {
            $dummy_object = new StdClass();
            array_push($arr, $dummy_object);
            $test_count++;
        }
        */
    
        for ($i=0; $i<$xml_count; $i++) {
            $dummy_object = new StdClass();
            $dummy_object->foo = $xml_children[$i]->attributes()->attr;
            array_push($arr, $dummy_object);
            $test_count++;
        }
    
    
        $arr_count = count($arr);
        echo '<br />CTRL+F for me:', $xml_count, '/', $test_count , '/', $arr_count, '<hr />';
        echo '<pre>', print_r($arr, true), '</pre>';
    }
    ?>
    

    Does it fix it for you?

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

Sidebar

Related Questions

EDIT3: It seems that the problem occurs on my localhost XAMPP PHP 5.3 setup,
I am experiencing a problem with Swing that only occurs when the computer monitor
Edit: [Solved] : It seems that the getTableCellRendererComponent of the CustomTableCellRenderer is called every
Which algorithms or data structures are used in auto-suggest features? It seems that edit-distance
EDIT : I completely re-wrote the question since it seems like I was not
It seems to me that this should work but I cant see what exactly
I'm getting a strange error that only occurs on the live server. My Django
I've noticed that if I build my WPF application for Any CPU/x64, it takes
Okay, here is my problem: I have a form that requires to have two
EDIT: This is not a problem with the jQuery creating the appropriate markup from

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.