Skip to content
Advertisement

how to remove white space from url in php

i am trying to remove white space from my url because i am using the url variable to query something in the database. but i keep getting %20 in my url which causes the database to return no values of such entry.

how can i remove it so that it doesnt cause this issue?

now this is what i tried but so far it is not working:

$userName = $row['username'];
            $escapeUpper = str_replace('%20','',"$userName");

how can i remove white spaces “%20” from my url?

Advertisement

Answer

Remove the quotes around $userName

$escapeUpper = str_replace(‘%20’,”,$userName);

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement