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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:31:39+00:00 2026-05-26T16:31:39+00:00

I am currently using the following code to convert my strings to seo friendly

  • 0

I am currently using the following code to convert my strings to seo friendly urls:

        function url($url) {
    $url = str_replace(" ", " ", $url);
    $url = str_replace(array("'", "-"), "", $url); 
    $url = mb_convert_case($url, MB_CASE_LOWER, "UTF-8");
    $url = preg_replace("#[^a-zA-Z]+#", "-", $url); 
    $url = preg_replace("#(-){2,}#", "$1", $url); 
    $url = trim($url, "-"); 
        return $url;
} 

When I query my database I match the url against the article titles in my database, my problem is that after performing the seo friendly url function the urls do not match any article titles in my database.

The addition of dashes (not sure about the lowercase) means that they are completely different to the entries in the database.

What is my next step, should I remove the dashes before querying the database, if so how?

Or is it better practice to include the article id in my url somewhere and reference it?

  • 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-26T16:31:39+00:00Added an answer on May 26, 2026 at 4:31 pm

    Querying by id seems far faster and simplier to me than reconverting back your titles, using url rerwriting to ignore the title (just for referencement) and call a page with the id as a GET argument. Looking at the current URL let me think that StackOverflow works this way.

    Using the current page as an example, i suspect that

    http://stackoverflow.com/questions/8034788/php-how-can-i-replace-dashes-with-spaces
    

    is rewritten to something like

    http://stackoverflow.com/questions.php?id=8034788
    

    where a simple SQL query gets the content of the article.

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

Sidebar

Related Questions

I'm currently using the following PHP code: // Get all subordinates $subords = array();
I am currently using the following code to create a web request: Dim myRequest
I'm currently using the following code to append a X link to each element
I'm currently using the following code (C#): private static void PlayLoop(string filename) { Audio
I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
I am using currently the following code to populate a combobox: combobox.DataSource = datatable;
In short, currently I am using the following code to pull records from multiple
I'm currently downloading an HTML page, using the following code: Try Dim req As
I am currently using PHP_Beautifier for formatting code with the following command like options
Currently I authenticate users against some AD using the following code: DirectoryEntry entry =

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.