小编Chr*_*iso的帖子

如何在 PHP 中删除字符串末尾的点 (.)

我有一个名为“5 Fragen an ... xyz”的字符串(wordpress 标题),在删除 HTML 标签后,该标题中的点应该被删除/替换。我除了字符串仅显示“xyz”

<?php
$wptitle = get_the_title($post->id); // getwordpress title
$wptitle = strip_tags($wptitle);    // remove a <br> tag
$wptitle = preg_replace('/\.(?=.*\.)/', ' ', $wptitle); // want to remove the dots
$wptitle = str_replace('5 Fragen an', '', $wptitle); // remove the part 5 Fragen an
echo $wptitle
?>
Run Code Online (Sandbox Code Playgroud)

php string replace

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×1

replace ×1

string ×1