【发布时间】:2009-08-14 11:36:51
【问题描述】:
目标是统计一组用户文本中的段落数...
(对于这个练习,我假设它总是大于 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;
?>
谢谢
【问题讨论】:
标签: php syntax syntax-error