目标是计算一组用户文本中的段落数......
(对于这个练习,我假设它总是大于 5 段)
然后我想要 1/2 的段落数,四舍五入并echo "yehhoo"
在中间输入一些内容()。
我确实理解我得到我的$newvalue
方式不是很好,也希望得到帮助......
<?php
$choppedup = explode("<p>",$node->field_long_body[0]['safe']);
$choppedpos = count($choppedup);
$choppedpos2 = $choppedpos/2;
$newvalue = floor($choppedpos2);
//I know this is working to here... the rest not so sure.
for($j = 0; $j < $choppedup; $j ++):
print $choppedup[$j];
if ($j == $newvalue):
echo "yehhoo" ;
endif;
endif;
?>
谢谢