我试图通过使用两个定界符爆炸来获得两个 foreach 循环<>
,"\n"
但出现错误。Warning: Invalid argument supplied for foreach()
这是我的代码
<?php
$specifications = $scooter_meta->get_the_value('specifications');
$titles = explode('<>', $specifications);
$descs = explode("\n", $specifications);
echo '<dl>';
foreach($titles as $title => $descs){
echo '<dt>' . $title . '</dt>';
foreach($descs as $desc){
echo '<dd>' . $desc . '</dd>';
}
}
echo '</dl>';
?>
进入textarea的值是这样的Title here<>this is the first scooter ever made.
Title here 2<>another line for specification
事实上我想让它像<title 1> here detail text
非常感谢