Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4541912
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:18:44+00:00 2026-05-21T15:18:44+00:00

I would like to write a router that is parsing an URL such as

  • 0

I would like to write a router that is parsing an URL such as I am giving it the rules and after that I would like to have an array that is name based.

======

EDITED:

So I did rewrite the code a little bit
the new code can be found here:
http://pastebin.com/Ver601FF

The outcome can be seen here:
http://img824.imageshack.us/i/phpprob.png/

What I now dont get is the way I could match the url values according to the regex within an array that has the indexes as the second route param has.

========================EDIT STOP==================
At the end I would like to have an array:

$request['controller']
$request['action']

as the basic $request params, as I need them all the time- therefore this has to be my standard / default route.

So lets say the $pattern[2] is happening, when I finish with this horrible regex I would like to have this:

$request['controller']
$request['action'] = show
$request['id']
$request['name']

obviously everything has to be filled accordingly depending on the requested url…

It dont know if it is because of its late or not, but I cant figure out, how I have to match those things.

Do I need to split the url and after I was checking if it matches a route? and then work with the values that they go to each others.

Another problem where I dont know a solution to is the fact, that an url such as

“/information/show/some/other/stuff”

has to give me back something like

$request['controller']  = information
$request['action'] = show
$request['params'] = array(some, other, stuff)

I appreciate anykind of help and hope that somebody can help me out of this trouble 🙁

Thank you very much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T15:18:44+00:00Added an answer on May 21, 2026 at 3:18 pm

    I found out the answer to my question on my own – I hope it helps somebody out there. But I might even publish it somewhere after a little freshup.

    Check out the solution:
    http://pastebin.com/FAbhneMZ

    I am going to rewrite it now and produce a proper class out of it, if there is anybody who is thinking that the logic in this little router can be improved please let me know!

    All the best guys.

    EDIT
    changed the link because that version was still buggy and not good and this is the final solution I am using and after 2 days more testing I think its just working the way I needed it. Hope it helps somebody else!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a cross-platform function in C++ that contains system calls.
I would like to write an if statement that will do something base on
I would like to write a method in ruby that takes a class with
I would like to write a command line tool that passes some formatted text
I have some classes in C++ that I would like to expose to Lua.
I would like to write an HTTP server that answer to request using a
I would like to implement a URL rewrriter for DotNetNuke. Have questions as to
I would like to know if it is possible to write some software that
I would like to write a navigation software for windows phone 7 that is
I would like to write a program that will find bus stop times and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.