url - Probelm with "comma" and urlencoding PHP -


on site, user can enter text in field called "description". can whatever text entered performing query , returning $description. want use information build url. running issues if user enters "," in part of text. example, let's user entered "test description, test description".

$description return as: "test%20description,%20test%20description"

running urlencode($description) results in: "test+description%2c+test+description"

this okay "test+description" part, not %2c. asking is, how can instead return: "test+description,+test+description"

well, urlencode encodes comma character %2c in hexadecimal notation, , that's cannot change: http://www.obkb.com/dcljr/charstxt.html

if don't want comma encoded guess should encode except commas:

str_replace('%2c', ',', urlencode($description)); 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -