在我的自动完成下拉搜索中 '&'
显示为 '&'
如何将其保持为 '&'
这是我的下拉php代码
$term = trim(strip_tags($_GET['term']));
$term = str_replace(' ', '%', $term);
$qstring = "SELECT name as value, client_id FROM goa WHERE name LIKE '" . $term . "%' limit 0,5000";
$result = mysql_query($qstring);
$qcount = 0;
if ($result) {
while ($row = mysql_fetch_array($result)) {
$row['value'] = htmlentities(stripslashes($row['value']));
$row['id'] = (int) $row['client_id'];
$row_set[] = $row; //build an array$qcount= $qcount + 1;}}echo json_encode($row_set); //format the array into json data
}
}
最佳答案
要从字符串中删除 &
,您可以使用 html_entity_decode
while ($row = mysql_fetch_array($result)) {
$row['value'] = html_entity_decode($row['value']);
$row['id'] = (int) $row['client_id'];
$row_set[] = $row;
}
关于php - 如何将 & 转换为出现在自动完成下拉列表中的 &,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31800990/