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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:05:44+00:00 2026-05-25T19:05:44+00:00

I have read through all the questions regarding this, and would like to know

  • 0

I have read through all the questions regarding this, and would like to know if $str = preg_replace('/[^\00-\255]+/u', '', $str); is sufficient for my scenario.

My Scenario

When a user creates an account on my site, he enters his company’s name. This can be anything including text with ' or " or even some other strange characters. When he creates an account, I need to create a folder on my server for him to access his account easier without using uniqids etc.

So for example you create an account for “Peter’s Pet Shop & Washing” – I would need to remove all spaces and characters that would not be allowed as a url-address. So at the end I need to have “peterspetshopwashing”

This is so that you can access your account at “www.mydomain.com/peterspetshopwashing”

  • 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-25T19:05:45+00:00Added an answer on May 25, 2026 at 7:05 pm

    I currently use this function I’m happy with

    function url($url) {
       $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url);
       $url = trim($url, "-");
       $url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
       $url = strtolower($url);
       $url = preg_replace('~[^-a-z0-9_]+~', '', $url);
       return $url;
    }
    

    it replaces spaces and other odd characters with - so result will be peter-s-pet-shop-washing

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

Sidebar

Related Questions

this is a noobie question regarding tree maps. I have read through the Java
I have read through other questions on this site - using the example answer
Okay guys, I have read through all the other posts and question on jQuery
I've read through the various posts on SO about this, but have still not
First, thanks in advance for taking the time to read through this. I have
I've read a couple similar questions regarding this topic on StackOverflow, but none of
First of all, I know there are a few other StackOverflow questions about this
I have read through all the threads out there that looked as if they
I have read through some of the suggested questions but I am not sure
I have read through the Rails docs for Routing , Restful Resources , 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.