我正在尝试删除/过滤“位置”中的流浪字符/字词。我的数组中的部分。到目前为止,无论我做什么,这样做都会输出我不想要的角色。
我想摆脱的角色:pic \ u00a0map
代码:
$city = 'Kanosh';
$s = "SELECT * FROM `list` WHERE `city` LIKE '%".$city."%'";
$res = $mysqli->query($s) or trigger_error($mysqli->error."[$s]");
$a = array();
while($row = $res->fetch_array(MYSQLI_BOTH)) {
$a[] = array(
'title' => $row['title'],
'price' => $row['price'],
'rooms' => $row['rooms'],
'dimensions' => $row['dimensions'],
'location' => preg_replace('pic\u00a0map', '', $row['location']),
'price' => $row['price'],
'address' => $row['address'],
'seller' => $row['seller'],
'href' => $row['href'],
'date' => $row['date']
);
}
header('Content-Type: application/json');
echo json_encode($a);
$res->free();
$mysqli->close();
输出:
[{"title":"Mobile Home Double Wide","price":"$85000","rooms":"3br","dimensions":"","location":"Kanosh UT pic\u00a0map","address":"","seller":"real estate - by owner","href":"http:\/\/saltlakecity.craigslist.org","date":"20140811214226"}, {"title":"Mobile Home Double Wide","price":"$85000","rooms":"3br","dimensions":"","location":"Kanosh UT pic\u00a0map","address":"","seller":"real estate - by owner","href":"http:\/\/saltlakecity.craigslist.org","date":"20140811223113"}]
请告知如何删除/过滤/替换数组元素内的字符和/或单词。