• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP array question

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

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

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

#4
[eluser]frist44[/eluser]
see above.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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