[nycphp-talk] preg_match (related to Many pages one script discussion)
chsnyder at gmail.com
Mon Aug 6 21:56:38 EDT 2007
On 8/6/07, Michael B Allen <ioplex at gmail.com> wrote:
> It so happens I'm working on a CMS component and the 'Many pages one
> script' discussion has inspired me to add mod_rewrite capability. I
> have a catch-all RewriteRule that just sends everything through
> index.php at the top of which I have a "handler table" that maps the
> REQUEST_URI to a handler class. I'm using preg_match to do the match
> and collect the parameters.
> So an example regex looks like:
> This works fine with REQUEST_URIs like:
> but it does not match any of the following:
> I would like to match these. For example, if the day parameter is not
> provided the match array returned by preg_match should simply have one
> fewer elements.
> So how does one designate parts of a preg_match expression as optional?
How optional? Why use preg_match at all?
list( $app, $year, $month, $day ) = explode( '/', $uri );
More information about the talk