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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:54:32+00:00 2026-05-29T19:54:32+00:00

I have a query in a php string which i am trying to filter

  • 0

I have a query in a php string which i am trying to filter against % signs.
The whole thing is in utf-8.
If the string contains % (for example %acheron) it gets converted to its equivalent entity (in the case I mention it becomes the ‘not’ sign character which is interpreted by the %ac sequence in the string).
I cant seem to be able to clean the incoming string of this character/
I cant clean the string with a php replace because by the time its in the script it is already “decoded?”.

The only way I found that I could figure out was to use rawurlencode and then clean it but it seems like a crappy solution and one that creates problems with other characters for me.

Is there some more efficient way to clearing these characters without affecting the rest of the string ? for instance I am looking for a function that would strip % & # (and any other) from the string, but leave it intact otherwise. (preg_replace is not working for me)

In other words is there a way to accept the string and clean it without any potentially special characters getting converted so that I can strip them from the string.

EDIT: The query is coming in via GET, wasn’t clear on that.
EDIT2: With urlecode or rawurl encode :
%acheron is converted to %ACheron (which could be cleaned I guess) but
^acheron is converted to %5Eacheron (thus making it almost impossible to clean it via a pattern)…

Please excuse the noobishness of my question
Thanks
Larry

  • 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-29T19:54:33+00:00Added an answer on May 29, 2026 at 7:54 pm

    $string = preg_replace(“/(%|&|#)/”, ”, $string);

    Something like this? This should work, if I understood your problem.

    EDIT: Ok this is what you’re looking for:

    <?php
    function myUrlEncode($string) {
        $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D', '%5E');
        $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]", "^");
        return str_replace($entities, $replacements, urlencode($string));
    }
    
    
    $search = myUrlEncode($_GET['id']);
    $search = preg_replace("/(%|&|#)/", '', $search);
    
    echo $search;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mysql query which I am running with php like so.
I have this php code, with which I am trying to generate a popup
I have a query like this (Mysql 5.X, PHP - formatted for legibility) $query
I have a php script that runs a mysql query, then loops the result,
So i have this script: <?php $query = mysql_query( SELECT meetup AS text, id
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I have a PHP file which inserts $mail and $password in my database. See
I have a var dump of my sql query which return the following I
i have a form in which if the user enters the search query, its
I'm trying to get 'clean' PathInfo style URLs with query string parameters working on

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.