foreach($array["$new"]['features'] as $key => $feature) :
$features .= <<< ____EOT
<li> $feature </li>
____EOT;
endforeach;
当前,我正在使用heredoc语法,但这有其缺点。还有其他PHP方法可以使用Heredoc语法完成相同的操作吗?
只需使用字符串。
$features .= "<li> $feature </li>";
Heredoc的优点是您不必担心在值中转义引号,因此对于较长的HTML块非常有用。