捕获var_dump输出

时间:2016-03-21 01:10:34

标签: php

我有以下代码:

$img_title_display = mysqli_query($db, "SELECT DISTINCT title FROM images WHERE user_id='$user_id' ORDER BY title");

while($row = $img_title_display->fetch_assoc())
{   
    var_dump($row['title']);
}

,输出如下:

string(6) "title1" string(6) "title2" string(6) "title3" string(6) "title4" string(6) "title5" string(6) "title6" string(6) "title7" string(6) "title8"

如何清除输出以便它就像:title1 title2 title3 title4 title5 title6 title7 title8?

3 个答案:

答案 0 :(得分:0)

你应该只使用echo函数

答案 1 :(得分:0)

echo '<pre>'.print_r($row['title'],1).'</pre>';

foreach($row['title'] as $title){
 echo '<pre>'.print_r($title,1).'</pre>';
}

答案 2 :(得分:0)

$img_title_display = mysqli_query($db, "SELECT DISTINCT title FROM images WHERE user_id='$user_id' ORDER BY title");

while($row = $img_title_display->fetch_assoc())
{   
    echo $row['title'];
}