我有一个 jQuery 脚本,它 onClick Button 请求并从 PHP 文件导入值并将这些值插入到表单中。
现在我可以成功地获取正确字段的值,但问题是这些值包含 HTML 代码,我只需要 TEXT结果。
我需要字段的值:“种族”和值应该是:“高加索人”
我尝试了不同的方法来查看的值$ethnicity
和有线的东西是:
echo $ethnicity; // result: Caucasian
var_dump($ethnicity); // result: string(146) " Caucasian "
$result['ethnicity'] = $ethnicity; // result: {"ethnicity":" Caucasian<\/td>\r"}
如您所见, $result 值为:"Caucasian<\/td>\r"
我也试过:
$result['ethnicity'] = ($ethnicity->textContent); // result: It says "null"
我的问题是:如何从这个值中删除这个 HTML 代码?