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 8721123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:10:13+00:00 2026-06-13T07:10:13+00:00

I have an array containing all routes/urls and their path, Example : $route =

  • 0

I have an array containing all routes/urls and their path,

Example : $route = array(
'/' => 'files/index.php',
'pages' => 'files/pages.php',
'pages/add' => 'files/page-add.php',
'posts/*' => 'files/posts.php',
)

Using array_key_exists() i check if a route exists in the array and if yes then load its path and it works if a direct match is found.

I want it to match to posts/* path whenever a request is made to posts/anything, posts/view/10, And i cannot do this using array_key_exists().

Do you guys have any ideas/suggestions on which method i should use?

  • 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-06-13T07:10:14+00:00Added an answer on June 13, 2026 at 7:10 am

    Do a combination of two strategies:

    • stick with your ‘routing array’ for the direct matches, that is a secure solution with good performance.
    • for remaining requests that gave no direct match try additional strategies like a regular expression based pattern matching, typically using phps preg_match() function. This gives you endless possibilities to describe patterns, though it obviously is slower than looking for direct matches.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of variables all containing text. I want to select only
I have an array containing a list of files. I want to sort it
I have an array.. [1,2,3,4] and I want a string containing all the elements
I have a 2D array containing all the Piece objects, each an instance of
I have an array containing all string values. Contents of the array are order_id,
I have an array containing numbers 1-5 (sometimes more). All the members in the
I have this array, in which each index contains an object literal. All of
I have a array containing japanese caracters as well as normal. How do I
I have an array containing specific times and I want when the current time
Ruby 1.8.6 I have an array containing numerical values. I want to reduce it

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.