PHP implodes without return

0

// I would like to do an implode that returns the numbers in the following order 1,2,3

class Users extends DB{
 //extende a classe de conexao com a database
static function getIds($user_id){

    $select = self::getConn()->prepare('SELECT id FROM 'users'');
    $select->execute(array($user_id));

    $d['data'] = $select->fetchAll(PDO::FETCH_ASSOC);
    return $d;
    }
}

//classe de ids dos usuarios "Users"

$user_id = 1;   
$uid = Users::getIds($user_id);

foreach($uid['data'] as $k){
    $arr_ids = array('id' => $k);

    var_dump($arr_ids);
//tentei usar o implode(',', $arr_ids['id']); e não retornou 1,2,3 
/*ira imprimir:
array (size=1)
0 => 
 array (size=1)
   'id' => string '1' (length=1)
 array (size=1)
0 => 
array (size=1)
   'id' => string '2' (length=1)
array (size=1)
0 => 
array (size=1)
  'id' => string '3' (length=1)
*/
}
    
asked by anonymous 30.06.2016 / 22:03

1 answer

1

To get this result, the array in question should be in the following format:

foreach($uid['data'] as $k){
   $arr_ids[] = $k;
}

This should be outside FOREACH

    
30.06.2016 / 22:16