What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP help

PHP help
Author: Message:
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: PHP help
quote:
Originally posted by Ezra
I'm trying to mod my blog a little, I want to add a function that automaticly adds Wikipedia links.

So when i type [[wiki]RAM] It makes it <a href="http://en.wikipedia.org/wiki/RAM">RAM</a>
Preg is better, IMO.

code:
$string = preg_replace("/\[\[wiki\](.+)\]/i", '<a href="http://en.wikipedia.org/wiki/$1">$1</a>', $string);

quote:
And maybe even support for different languages like

[[wiki:nl]RAM] for http://nl.wikipedia.org/wiki/RAM and
[[wiki:en]RAM] for http://en.wikipedia.org/wiki/RAM

I'm not really a hero with advanced string replacers :P, so any help is appreciated :)
code:
$string = preg_replace("/\[\[wiki:([a-z]{2})\](.+)\]/i", '<a href="http://$1.wikipedia.org/wiki/$2">$2</a>', $string);

Not sure, didn't test it. Variable name should be changed to the variable name you use for your post text. (Y)

Edit: corrected a lot of typos :p


Edit 2: @ WDZ => preg_ > ereg/i :refuck:

Edit 3: can be quite buggy if you use many tags in the same post... cbb to fix it :p

This post was edited on 09-30-2005 at 10:06 PM by L. Coyote.

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

09-30-2005 06:10 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
PHP help - by Ezra on 09-30-2005 at 05:03 PM
RE: PHP help - by J-Thread on 09-30-2005 at 05:24 PM
RE: PHP help - by Ezra on 09-30-2005 at 05:37 PM
RE: PHP help - by L. Coyote on 09-30-2005 at 06:10 PM
RE: PHP help - by Ezra on 09-30-2005 at 06:16 PM
RE: PHP help - by WDZ on 09-30-2005 at 06:35 PM
RE: PHP help - by Ezra on 09-30-2005 at 06:55 PM
RE: PHP help - by brian on 09-30-2005 at 07:14 PM
RE: PHP help - by Ezra on 09-30-2005 at 08:38 PM
RE: PHP help - by J-Thread on 09-30-2005 at 08:58 PM
RE: PHP help - by Ezra on 09-30-2005 at 10:15 PM
RE: PHP help - by WDZ on 10-01-2005 at 04:03 AM
RE: PHP help - by J-Thread on 10-01-2005 at 08:22 AM
RE: PHP help - by -dt- on 10-01-2005 at 09:29 AM
RE: PHP help - by J-Thread on 10-01-2005 at 11:08 AM
RE: RE: PHP help - by -dt- on 10-01-2005 at 02:11 PM
RE: PHP help - by L. Coyote on 10-01-2005 at 04:16 PM
RE: PHP help - by Ezra on 10-01-2005 at 05:47 PM
RE: RE: PHP help - by -dt- on 10-02-2005 at 05:14 AM
RE: PHP help - by J-Thread on 10-01-2005 at 06:03 PM
RE: PHP help - by Ezra on 10-02-2005 at 12:59 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On