You are here: Re: calling a function through user input. « PHP Programming Language « IT news, forums, messages
Re: calling a function through user input.

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация