• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UGH! Arrays are giving me a headache :(

#2
[eluser]Sumon[/eluser]
[quote author="Kinsbane" date="1222299031"]
I have my code grab this dataset with an object, and then I try to loop through the object with this:
Code:
foreach($divisions->result_array() as $row)
{
    die(print_r($row)); //just to see what I get
}
However, this only gives me the first record in the dataset ([id] of 1).
[/quote]
First record in the dataset because die() function stop execution immediately after first print_r($row); statement

[quote author="Kinsbane" date="1222299031"]
All I want to do is take that result set and put it into the $data array like this:
Code:
$data['division'][$key] = $value;
But everything I'm trying isn't working - it's leaving me stuck at the first level of arrays, which then contain arrays which get at the values I need.[/quote]
Try to use:
Code:
foreach($my_array as $key=>$value)
{
    $data['division'][$key] = $value['division_code'];
}
print_r($data['division']); //display what have stored
Is it what you want?


Messages In This Thread
UGH! Arrays are giving me a headache :( - by El Forum - 09-24-2008, 12:30 PM
UGH! Arrays are giving me a headache :( - by El Forum - 09-24-2008, 02:00 PM
UGH! Arrays are giving me a headache :( - by El Forum - 09-24-2008, 02:24 PM
UGH! Arrays are giving me a headache :( - by El Forum - 09-24-2008, 03:15 PM
UGH! Arrays are giving me a headache :( - by El Forum - 09-24-2008, 03:18 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.