gpt4 book ai didi

php - 分解数据库数组 PHP

转载 作者:搜寻专家 更新时间:2023-10-31 21:15:13 24 4
gpt4 key购买 nike

我正在尝试将从数据库数组中检索到的段落分解为单独的单词。这是执行此操作的正确方法吗,因为它当前给出一个错误,指出 explode() 需要 2 个参数,因此它一定不能拾取 $row 数组。

function words() {
$query = mysql_query("SELECT text FROM table WHERE textID = 1");
while($row = mysql_fetch_array($query)) {
$e[] = explode(" ", $row);
foreach($e as $r) {
echo $r;
}
}
}

最佳答案

function words() {
$query = mysql_query("SELECT text FROM table WHERE textID = 1");
while($row = mysql_fetch_array($query)) {
$e[] = explode(" ", $row[0]);
foreach($e as $r) {
echo $r;
}
}
}

$row 是数组。选择要 explode 的第一个元素。阅读 Explode 的文档.

关于php - 分解数据库数组 PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10371295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com