NYCPHP Meetup

NYPHP.org

[nycphp-talk] preg_match (related to Many pages one script discussion)

Michael B Allen ioplex at gmail.com
Mon Aug 6 23:01:18 EDT 2007


On 8/6/07, Jon Baer <jonbaer at jonbaer.com> wrote:
>
> Would be something like:
>
> @/news/([0-9]+)?/([0-9]+)?/([0-9]+)?@

Hi Jon,

That works great. Thanks.

> But I think it should either be a completely valid date or now by default.

Perhaps. I think it could make sense to have some parameters optional.
I really just wanted to make sure I know how to make URL parameters
optional.

> Also isn't there a mode to preg_match or a version in which you can get
> named parameters?

That's no problem. I have the parameter names in a parallel array so I
just loop through the matches and build a new array. Then my get_param
and set_param functions get or set params from or to $_POST, $_GET and
$url_params in that order of precedence. That abstraction also assists
with building URLs (e.g. if a parameter came from the URL you can
build a URL with URL parameters).

Thanks,
Mike

> On Aug 6, 2007, at 9:46 PM, Michael B Allen wrote:
>
>
>   '@/news/([0-9]+)/([0-9]+)/([0-9]+)@'
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>



More information about the talk mailing list