Tangler Discussion Forums

PHP

Discuss

Topics

Click a Topicto start discussing

    Not really sure how to explain what it is that I want to do but I'm hoping someone can point me in the right direction where I can find more info.

    A project that's been floating around in my head for a couple of years involves users creating documents in which they can insert snippets of code that automatically link to other documents. Sounds a bit like a wiki, I know, and that would be fairly close but I need to create my own parsing engine.

    For example, let's say a user is writing a document about airports and the sentence is something like "...and when visiting Brisbane, you'll land at ...". At this point they want to insert Brisbane International Airport. They do this by selecting that name from a drop-down list of airports. When they make the selection, the code for that airport, ::BNE::, is inserted and it's this code that's saved to the document.

    When this document is viewed on the website, ::BNE:: is replaced with Brisbane International Airport, and that text is hyperlinked to another page showing, say, all documents that include mention of that airport.

     

    So what I need to figure out is the best way to have it so that whenever a document is retrieved from the CMS/database for viewing, the document body is parsed for occurrences of ::BNE:: and they are then replaced with the name stored in the database (Brisbane International Airport) and a link.

    Does that make sense?

    2007-10-09 21:06:52.0

    Hi,

    It's quite simple, you just have to use preg_replace() function with regexps. It's not so hard. You can use POSIX, (ereg_*) or PCRE (preg_*). In your place I would use PCRE. About regexps you can find just by googling php.net site;)

    2007-10-16 00:40:39.0

    Awesome. Thanks.:) I hoped it would be something like that.:) Thanks again!

    2007-10-18 20:42:36.0
To send a message, Join Now (it's quick and free) or Sign In
Edit Topic
Delete Topic
Are you sure you want to delete the topic