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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:14:35+00:00 2026-05-19T11:14:35+00:00

I think I have the need to take a uri which has been decoded

  • 0

I think I have the need to take a uri which has been decoded in PHP, and re-encode it.

Here is the situation:

  1. JavaScript passes encoded uri as query string parameter to php script.
  2. PHP script embeds uri as a hidden input value in an html document, responds with the document to a user agent.
  3. JavaScript reads embedded uri and sets location of current document based on value of hidden input.

On Step 2, I am finding that the Uri is fully decoded after reading it in via $_GET. So when I embed the uri in the hidden input, it becomes un-encoded. So I would like to run a PHP script which re-encodes the Uri properly ex:

http://my.example.com/dog walk?is=very great

==>

http://my.example.com/dog%20walk?is=very%20great

Is there a pre-built php function for this or should I just write my own?

PLEASE NOTE: urlencode and urldecode are not the answer to get the desired input/output I have in the example above.

Thanks,
Macy

  • 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-19T11:14:36+00:00Added an answer on May 19, 2026 at 11:14 am

    I don’t know if will help you, but PHP have 3 useful functions:

    $url = parse_url('put the url here');
    parse_str( $url['query'], $query ); // generating an array by reference (yes, kinda weird)
    echo $query; //in this line, you can encode or decode.
    

    or, if you want to mount a query, you can use http_build_query(); that accepts values from an array, like:

    $url = 'http://my.example.com/dog walk?';
    $array = Array (
     'is' => 'very_great',
    );
    $url_created = $url . http_build_query($array);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Friends, I have a strange need and cannot think my way through the problem.
I think I know the answer to this but I have the need to
I have been playing around with Python's FTP library and am starting to think
I need to write code which should find distance of chars. I think i
I have a solution where i need to take different classes and access it's
I have a table, call it MyTable which has a column, say myvalue. I
I think I have this working but I need advice. I'd like to know
I have this thing that i need to do and some advices will be
I think I have a solution to this, but is there a better way,
I think I have a synchronization problem...It may be too basic..Please help.. I have

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.