PHP-字符串到html

PHP-字符串到html,php,html,Php,Html,我有一个php字符串数组。看起来是这样的: $array = ['text-1' => '<p>Hello</p><span class="my-custom-class">random text here</span>']; $array=['text-1'=>'Hellorandom text here']; 当我将其回显到html中时,它不会将标记转换为html,而是按数组中的原样显示。如何将其转换为html 谢谢你的建议我们开始吧

我有一个php字符串数组。看起来是这样的:

$array = ['text-1' => '<p>Hello</p><span class="my-custom-class">random text here</span>'];
$array=['text-1'=>'Hello

random text here'];
当我将其回显到html中时,它不会将标记转换为html,而是按数组中的原样显示。如何将其转换为html

谢谢你的建议我们开始吧

foreach($array as $key => $value) {
    echo "<!--begin $key-->".$value."<!-- end $key -->";
}
foreach($key=>$value的数组){
回显“$value.”;
}
或者如果你想把东西缓冲起来,推动一个大的写操作

$output = "";
foreach($array as $key => $value) {
    $output .= "<!--begin $key-->".$value."<!-- end $key -->";
}
echo $output;
$output=”“;
foreach($key=>$value的数组){
$output.=''.$value.'';
}
echo$输出;
您可以尝试以下方法:

$array = array('text' => '<p>Hello</p><span class="my-custom-class">random text here</span>');
foreach ($array as $key => $value) {
  echo htmlentities($value);
}
$array=array('text'=>'Hello

random text here'); foreach($key=>$value的数组){ 不动产(价值); }
如何输出?这应该是一个安全防范措施如果您在网页中看到标记,听起来数组实际上包含HTML实体代码,而不是问题中显示的HTML。