Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Array limiting at 50

    Hello. I have a script that combines many arrays into one giant array. The giant array should have 115 arrays within, but it only ever displays 50.

    The code I have is something like this

    Code:
    $array_1 = array(
                                array('id' => 1, 'message' =>1)
                                array('id' => 2 , 'message' => 2),
                                ...
                                array('id' => 50 , 'message' => 50),
                        );
    
    $array_2 = array(
                                array('id' => a1, 'message' =>a1)
                                array('id' => a2 , 'message' => a2),
                                ...
                                array('id' => a50 , 'message' => a50),
                        );
    
    $final_array = $array_1 + $array_2;
    
    return $final_array;
    I use codeigniter and I return the $final_array to the view. Even though the above should have 100 array objects, it only ever returns 50. (0-49). Any ideas?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You need to determine if the issue is with your CMS or if its with the array. You can use var_dump(array_keys($final_array)); to see how many offsets exist within it. If it matches what you expect, that would indicate its your framework limiting it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Mar 2012
    Posts
    63
    Thanks
    7
    Thanked 0 Times in 0 Posts
    This is what I got in response. Any ideas as to why is the array being limited?

    array(50) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) [10]=> int(10) [11]=> int(11) [12]=> int(12) [13]=> int(13) [14]=> int(14) [15]=> int(15) [16]=> int(16) [17]=> int(17) [18]=> int(18) [19]=> int(19) [20]=> int(20) [21]=> int(21) [22]=> int(22) [23]=> int(23) [24]=> int(24) [25]=> int(25) [26]=> int(26) [27]=> int(27) [28]=> int(28) [29]=> int(29) [30]=> int(30) [31]=> int(31) [32]=> int(32) [33]=> int(33) [34]=> int(34) [35]=> int(35) [36]=> int(36) [37]=> int(37) [38]=> int(38) [39]=> int(39) [40]=> int(40) [41]=> int(41) [42]=> int(42) [43]=> int(43) [44]=> int(44) [45]=> int(45) [46]=> int(46) [47]=> int(47) [48]=> int(48) [49]=> int(49) }

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    What's in $array_1 and $array_2?

    Edit:
    Actually, I don't need to know what's in there.
    You are sharing keys between $array_1 and $array_2 just from what you have here. Since it already exists in $array_1, you cannot override it with value of $array_2. Use array_merge instead of the +, as the + is using array_intersect_key.
    Knew there was a reason I never used addition operators with arrays.
    Last edited by Fou-Lu; 02-12-2013 at 05:43 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •