Page 1 of 1

imploding multidemential array

Posted: Sun Aug 15, 2010 8:49 pm
by GeXus
I have a result set from a DB that returns the following array.... how do I implode this into a comma delimited string? Thanks!

Code: Select all

Array
(
    [0] => Array
        (
            [user_id] => 2
        )

    [1] => Array
        (
            [user_id] => 5
        )

    [2] => Array
        (
            [user_id] => 11
}

Re: imploding multidemential array

Posted: Sun Aug 15, 2010 9:01 pm
by Gargoyle
multidemential
lol :)

other than that, use implode(array()) on the whole thing, user serialize() or array_walk() or do it the old-fashioned way:

Code: Select all

$a = array();
foreach(($arr as $v)
{
$a[] = $v['user_id'];
}
$a = implode(',',$a);
print_r($a);