CodeIgniter Forums

Full Version: PHP array question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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?

El Forum

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

El Forum

[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)

El Forum

[eluser]frist44[/eluser]
see above.