求一个用php将ubb转成html的脚本(要支持表格)

WBOY
Release: 2016-06-23 14:02:56
Original
738 people have browsed it

嗯,看到有些论坛上使用ubb的,还可以写表格。
其实能给出这一块的代码也行。
语法好像是
[tbl]
|a1|s2|s3|
|b1|b2|b3|
|c1|c2|c3|
[/tbl]
当然也可以用逗号分隔。
自己太弱了写不出来。。
谢谢


回复讨论(解决方案)

$s =<<< UBB[tbl]|a1|s2|s3||b1|b2|b3||c1|c2|c3|[/tbl]UBB;$s = preg_replace_callback('/\[tbl\](.+)\[\/tbl\]/isU', 'tbl_func', $s);echo $s;function tbl_func($r) {  $t = preg_replace( array('/^\|/m', '/\|\r?$/m', '/\|/m'), array('<tr><td>', '</td></tr>', '</td><td>'), $r[1]);  return "<table>$t</table>";}
Copy after login





a1 s2 s3
b1 b2 b3
c1 c2 c3


其他标记如法炮制
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!