帝国CMS多值字段for循环调用调用方法
2020-04-10 站长 站长日志
基础版
| 1 2 3 4 5 6 7 8 9 10 11 |
<?php$morefr=explode('||||||',$navinfor[字段名称]);$mfcount=count($morefr);for($mfi=0;$mfi<$mfcount;$mfi++){$morefrf=explode('::::::',$morefr[$mfi]);?><li><b><?=$morefrf[0]?></b><i><?=$morefrf[1]?></i><u><?=$morefrf[2]?></u></li><?php}?> |
自定义版本/适用于同页面多个地方不同组合的调用
| 1 2 3 4 5 6 7 8 9 |
<?php$morefr=explode('||||||',$navinfor[字段名称]);$mfcount=count($morefr);for($mfi=0;$mfi<$mfcount;$mfi++){$morefrf=explode('::::::',$morefr[$mfi]);$自定义名称1.=' '.$morefrf[0].' '.$morefrf[1].' '.$morefrf[2].' ';$自定义名称2.=' '.$morefrf[2].' '.$morefrf[3].' '.$morefrf[4].' ';?> |
调用: <?=$自定义名称1?> <?=$自定义名称2?>
倒序版本
| 1 2 3 4 5 6 7 8 9 10 11 12 |
<?php$morefr=explode('||||||',$navinfor[字段名称]);rsort($morefr); // 添加此行即可倒序$mfcount=count($morefr);for($mfi=0;$mfi<$mfcount;$mfi++){$morefrf=explode('::::::',$morefr[$mfi]);?><li><b><?=$morefrf[0]?></b><i><?=$morefrf[1]?></i><u><?=$morefrf[2]?></u></li><?php}?> |
