gpt4 book ai didi

php - 如何按条件过滤内爆结果?

转载 作者:行者123 更新时间:2023-11-29 02:41:41 25 4
gpt4 key购买 nike

我正在尝试内爆数据 MySQL 数据库。

我有这样的内爆结果:

1,2,3,4,5

我想要的是这样的(我想要结果中的第 3 个过滤器):

1,2,4,5

我做了什么:

$result = [];

$query = mysqli_query($koneksi, "SELECT * FROM user") or die (mysqli_error());

while($row = mysqli_fetch_assoc($query)){

$result[] = $row['id'];

$implode = implode(",", $result);

echo $implode;

有什么方法可以过滤该结果吗?

最佳答案

您可以使用“if”结构

Find this code:

$result[] = $row['id'];

如果你需要比较一个变量和一个值,而不是这样做:

Change this line with:

if($row['id'] != '3'){
$result[] = $row['id'];
}

关于php - 如何按条件过滤内爆结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50547947/

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