Welcome Guest, Not a member yet? Register   Sign In
implode the resulting result_array from a db query
#1

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

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

[eluser]sigsauer[/eluser]
all right, for each it is.

thank you!




Theme © iAndrew 2016 - Forum software by © MyBB