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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:01:36+00:00 2026-05-25T21:01:36+00:00

So I’m building a website that is using a database feed that was already

  • 0

So I’m building a website that is using a database feed that was already set up and has been used by the client for all their other websites for quite some time.

They fill this database through an external program, and I have no way to change the way I get my data.

Now I have the following problem, sometimes I get strings in UTF-8 and sometimes in ASCII (I hope I’ve got these terms right, they’re still a bit vague to me sometimes).

So I could get either this: Scénic or Scénic.

Now the problem is, I have to convert this to non-special characters (so it would become Scenic) for urls.

I don’t think there’s a function for converting é to e (if there is do tell) so I’ll probably need to create an array for that containing all the source and destinations, but the bigger problem is converting é to é without breaking é when it comes through that function.

Or should I just create an array containing everything
(so for example: array('é'=>'e','é'=>'e'); etc.

I know how to get é to é, by doing utf8_encode(html_entity_decode('é')), however putting é through this same function will return é.

Maybe I’m approaching this the wrong way, but in that case I’d love to know how I should approach 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-25T21:01:37+00:00Added an answer on May 25, 2026 at 9:01 pm

    Thanks to @XzKto and this comment on PHP.net I changed my slug function to the following:

    static function slug($input){
    
        $string = html_entity_decode($input,ENT_COMPAT,"UTF-8");
    
        $oldLocale = setlocale(LC_CTYPE, '0');  
    
        setlocale(LC_CTYPE, 'en_US.UTF-8');
        $string = iconv("UTF-8","ASCII//TRANSLIT",$string);
    
        setlocale(LC_CTYPE, $oldLocale);
    
        return strtolower(preg_replace('/[^a-zA-Z0-9]+/','-',$string));
    
    }
    

    I feel like the setlocale part is a bit dirty but this works perfectly for translating special characters to their ‘normal’ equivalents.

    Input a áñö ïß éèé returns a-ano-iss-eee

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't

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.