CodeIgniter Forums
PHP array question - 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: PHP array question (/showthread.php?tid=25935)



PHP array question - El Forum - 12-31-2009

[eluser]frist44[/eluser]
I don't know why i'm having so much trouble with this. I did a sql select and my outcome is:

name => xxxxx for each row.

So I'm attempting to make a helper that would add:

value=> $row['name'] for each row, but I'm stuck.

I have:

Code:
foreach ($xArr as $row){
  $row['value'] =  $row['name']
}

but i know that's not right. any help?


PHP array question - El Forum - 12-31-2009

[eluser]frist44[/eluser]
Nevermind. I have to put it in by reference, or push it to a new array.


PHP array question - El Forum - 12-31-2009

[eluser]BrianDHall[/eluser]
Use the result_array() function and var_dump() functions to see what your results look like, and then you can better see what exactly you need to do.

Other than that, your question as of now is unanswerable because we don't know what data $xArr contains.

Unless you are looking for this:

Code:
foreach ($xArr as $key => $value)



PHP array question - El Forum - 12-31-2009

[eluser]frist44[/eluser]
see above.