|
Posted by Rami Elomaa on 05/04/07 06:02
"Mohawk Mawk" <blessblessbless@gmail.com> wrote in message
news:1178255378.399380.81860@p77g2000hsh.googlegroups.com...
> Hey guys.
> So heres yet another question to a problem where I would have no idea
> where to look for the answer for so I turn to you :)
>
> Say my sites administrator wants to write a news update or blog or
> whatever. Something like this
>
> "Added a new gallery from my trip to Phuket, enjoy:
> [GID=24]
> If you liked it tell me."
>
> I want the [GID=24] to get replaced by my galery loading function
> (very nifty and handy) so it would turn into something like this
>
> echo "Added a new gallery from my trip to Phuket, enjoy:
> ".galery($GID)."
> If you liked it tell me.";
>
>
> I chose this [GID=24] because it is similar to burning board code. I
> would also like to include a command like [PID=45] witch would run my
> picture function.
>
> any ideas what functions I am looking for?
preg_replace_callback()
http://fi2.php.net/manual/en/function.preg-replace-callback.php
example:
preg_replace_callback('/\[GID=([\d]+)\]/', 'galery', $input);
But galery will recieve an array of matches, not just an id, so you'll maybe
need to modify it a bit. Also I haven't tested this at all, the example is
just to illustrate the idea...
--
Rami.Elomaa@gmail.com
"Good tea. Nice house." -- Worf
[Back to original message]
|