So you want to replace the spaces, but not any of the non-alpha characters? Sounds more like a preg_replace() action. That way you could just create an array of patterns you want to replace, rather than doing a real urlencode.

-Don Pickerel-

On 3/11/2010 9:17 AM, nitin gupta wrote:
Thanks Earnie, but that is not what I am looking for. It is essentially similar to urlencode or rawurlencode. I am looking for a function that does the work like the one present at the bottom of the page here:

http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

For eg:

http://example.com/q=12 &12grt key=value;<>+,.()!*

is converted to

http://example.com/q=12%20&12grt%20key=value;%3C%3E+,.()!* <http://example.com/q=12%20&12grt%20key=value;%3C%3E+,.%28%29%21*>


--
Regards,
Nitin Kumar Gupta
http://publicmind.in/blog/


On Thu, Mar 11, 2010 at 7:32 PM, Earnie Boyd <[email protected] <mailto:[email protected]>> wrote:

    nitin gupta wrote:

         Hi,

         I am not creating the URL, but I parse the URL from XML
        content and I
         want to urlencode it. Also, I am looking to preserve all the
        reserved
         characters in the URL and not just '?' or '&'.


    http://www.google.com/search?q=url+encoding+site%3Aapi.drupal.org
    leads you to two api functions url [1] and drupal_urlencode [2].
     Are these what you need?

    [1] http://api.drupal.org/api/function/url
    [2] http://api.drupal.org/api/function/drupal_urlencode

    --
    Earnie
    -- http://www.give-me-an-offer.com



Reply via email to