使用PHP将HTML替换为HTML [英] Use PHP to Replace HTML with HTML
问题描述
//函数添加到您的函数定义中。
函数print_processed_html($ string)
{
$ search = Array( - ,*,\ *,^,\ ^);
$ replace = Array(< \ hr>,< b>,< \ b>,⊃>,< \ sup> ;
$ processed_string = str_replace($ search,$ replace,$ string);
echo $ processed_string;
}
//输出字符串到页面。
<?php
$ the_content = get_the_content();
print_processed_html($ the_content);
?>
也可以通过阅读 the_content()函数的一些技巧 / p> Is there a way to use PHP to find some HTML within a page, and replace that HTML with other HTML? I'd like for this function to be in a separate functions.php file, and look at each page on page-load for the HTML that needs replacing (unless this isn't as efficient as some other method). Thanks! also consider reading through this http://codex.wordpress.org/Function_Reference/the_content for some tips on using the 这篇关于使用PHP将HTML替换为HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!//function to add to your function definitions.
function print_processed_html($string)
{
$search = Array("--", "*", "\*", "^", "\^");
$replace = Array("<\hr>", "<b>", "<\b>", "<sup>", "<\sup>");
$processed_string = str_replace($search, $replace , $string);
echo $processed_string;
}
// outputing the string to the page.
<?php
$the_content = get_the_content();
print_processed_html($the_content);
?>
the_content()
function