![]() |
Finding Value in Array using isset - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Finding Value in Array using isset (/showthread.php?tid=24352) Pages:
1
2
|
Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]Fielder[/eluser] Code: echo 'Before merge: start'; Quote:Before merge: startarray(11) { ["storename"]=> string(9) "Appletree" ["storenum"]=> string(3) "736" ["newAd_count"]=> int(4) ["renewAd_count"]=> int(4) ["totAd_count"]=> int(8) ["spaces_count"]=> int(10) ["print"]=> string(1) "Y" ["lastqtrAd_count"]=> int(9) ["cancelled"]=> int(1) ["freeAd_count"]=> int(4) ["revenue"]=> string(10) "$ 5,115.87" } endAfter merge: start So before merge, 2975 is there. After merge, 2975 is not there. But after the foreach loop, it adds back in 2975 because it is in $stores. Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]mah0001[/eluser] You can remove all the var_dumps. What is the value for the $subTotal? Code: $subTotal = $this->rtui_app->subTotal($storeArray); If $subTotal is not an array you cannot merge a string with the array. I think this is causing all the trouble. Try changing the $subTotal to an array. e.g. Code: $subTotal = $this->rtui_app->subTotal($storeArray); Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]Fielder[/eluser] It looks like before the merge, the keys are the store_ids (ie 2975). After the merge, the keys in the original $storeArray were changed to 0, 1, 2, 3, etc... So somehow $storeArray[2975] is being changed to $storeArray[0]. I ran this code Code: echo '<hr />'; Maybe this helps. $storeArray keys before merge: Quote:2975 $storeArray keys after merge: Quote: 0 Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]Fielder[/eluser] I agree, the merge is causing the problem. Perhaps there's a different way to merge the Appletree, Fiesta, HEB, etc... keys to the existing 2975, 2732, etc... keys? That's all i really want to do is tack those $subTotal keys to the end of $storeArray. Yes, it's an array. Code: $subTotal = $this->rtui_app->subTotal($storeArray); Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]mah0001[/eluser] another way to merge arrays: Code: $subTotal = $this->rtui_app->subTotal($storeArray); Finding Value in Array using isset - El Forum - 11-08-2009 [eluser]Fielder[/eluser] *&^$%#... I should have figured that out! It worked, and is simple. I guess I hone in on the error and problem and alternate solutions skip my mind. Thanks for the help. No reason to use array_merge since this solution worked. Seems that merging an array with numeric keys with an array with alpha keys screw it up.? Or perhaps merging resets all the keys? Thanks again mah0001. |