PHP函数的数据库值

我想调用一个php函数,返回数据库值。

public function readdata() { 
    $id = "";
    $name = "";
    $sth = $db->execute('SELECT * FROM mynumbers m WHERE m.id>1 ORDER BY m.id ASC');
    foreach ($sth as $s) {
       $id .= $s->id;
       $name .= $s->name;       
    }
    return compact('id', 'name');        
}

$rd = readdata();
$get_id = $rd['id'];
$get_name = $rd['name'];    
echo $get_id;
echo $get_id.$get_name.'<br>';

当我执行代码时,其输出显示为:

7891011
7Text1 | 8Text2 | 9Text3 | 10Text4 | 11Text5

但我想作为单个值垂直显示。我是否需要爆炸'| | '

评论