search
Homephp教程php手册一个ubbcode的函数,速度很快._php基础

前面见到有人发表
但是速度比较慢,也非常长
这里给出一种

function ubb($str) {  
$color=Array('red','blue','green');
$str=eregi_replace('\[url\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/url\]','\\1',$str);//url
$str=eregi_replace('\[url=http://([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','\\2',$str);
$str=eregi_replace('\[url=([a-zA-Z0-9@:%_.~#-\?&]+)\](.+)\[\/url\]','\\2',$str);
$str=eregi_replace('\[img\]([a-zA-Z0-9@:%_.~#-\?&]+)\[\/img\]','一个ubbcode的函数,速度很快._php基础\\1',$str);//img
$str=eregi_replace('\[h([1-6])\](.+)\[\/h[1-6]\]','\\2\\1>',$str);//h1-6
$str=eregi_replace('\[email\]([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\[\/email\]','\\1',$str);//email
$str=eregi_replace('\[email=([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})\](.+)\[\/email\]','\\2',$str);
$str=eregi_replace('\[b\](.+)\[\/b\]','\\1',$str);
$str=eregi_replace('\[i\](.+)\[\/i\]','\\1',$str);
$str=eregi_replace('\[size=(.+)\](.+)\[\/size\]','\\2',$str);
$str=eregi_replace('\[color=(.+)\](.+)\[\/color\]','\\2',$str);
$str=eregi_replace('\[sub\](.+)\[\/sub\]','\\1',$str);//下裱
$str=eregi_replace('\[sup\](.+)\[\/sup\]','\\1',$str);//上标
for($i=0;$i\\1',$str);
$str=preg_replace("/\[quote\](.+?)\[\/quote\]/is","

quote:
\\1
", $str);
$str=preg_replace("/\[code\](.+?)\[\/code\]/is","
code:
\\1
", $str);
$str=preg_replace("/\[sig\](.+?)\[\/sig\]/is","


--------------------------
\\1
--------------------------
", $str);
return $str;

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.