I have got an array from a database and I want to change some of the values like using ucwords() etc.
The problem is when i run the array through a foreach loop, it overwrites all the values in the array with the values of the last row in the array.
I've been racking my brains all afternoon and can't figure out what's going wrong.
foreach($rows as $key => $row) { //$rows['datetime'] = Forum::change_date(strtotime($row['postdate'])); $rows[$key]['board'] = strtolower(str_replace(array(' ','\''), array('-',''),$row['boardname'])); $rows[$key]['boardid'] = $row['boardno']; $rows[$key]['boardname'] = ucwords($row['boardname']); $rows[$key]['topicname'] = Words::shortenText($row['topicname'],30); }
I end up with the 6 rows in the array all the same.
Any ideas what I'm doing wrong?