implode the resulting result_array from a db query - 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: implode the resulting result_array from a db query (/showthread.php?tid=28002) |
implode the resulting result_array from a db query - El Forum - 02-26-2010 [eluser]sigsauer[/eluser] I'm trying to return the imploded resulting array from a query like this: $query="SELECT userfavorites.station_id from userfavorites WHERE userfavorites.user_id = $user"; $result = $this->db->query($query); return implode(",",array_values($result->result_array())); All I get is a string containing Array, Array, Array, Array, Array Isn't this possible without having to run a foreach loop? implode the resulting result_array from a db query - El Forum - 02-26-2010 [eluser]mah0001[/eluser] result_array() returns a multi dimensional array and it is not possible to flatten the result without iteration. If you want to have a ready made function, see: http://www.php.net/manual/en/function.array-values.php implode the resulting result_array from a db query - El Forum - 02-27-2010 [eluser]sigsauer[/eluser] all right, for each it is. thank you! |