简体   繁体   English

如何删除所有数组,仅显示消息?

[英]How do I delete all the arrays and only show the message?

I'm making a timeline-alike widget but I'm stuck at the fetchAll() function. 我正在制作类似时间轴的小部件,但我陷在fetchAll()函数中。

<?php
require('./dbconfig.php');
$userid = $_SESSION['user_session'];
$query = $DB_con->prepare("SELECT bericht FROM tijdlijn WHERE auteurid=:uid");
$query->execute(array(':uid' => $userid));

$tijdlijn=$query->fetchAll(PDO::FETCH_ASSOC);

print_r ($tijdlijn[1]);

?>

which results in this: 结果是:

Array ( [bericht] => Dit is een 2de test )

I just want 'Dit is een 2de test' to show up, not all the other stuff. 我只希望显示“ Dit iseen 2de test”,而不是其他所有内容。

I also want to show all the messages that are from the same author. 我还想显示来自同一作者的所有消息。 I have a script that only shows the messages to the author. 我有一个仅向作者显示消息的脚本。

The array is 2-dimensional, you also need to specify the second index or it will print the entire second dimension. 该数组是二维数组,您还需要指定第二个索引,否则它将打印整个第二维。

print_r ($tijdlijn[1]['bericht']);

The array it's first index is the row # of the output and the second index is the column name. 数组的第一个索引是输出的行号,第二个索引是列名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM