Jump to content

[SOLVED] url variable name itself has space in it... how can I retrieve it in php??


mac007

Recommended Posts

Hi, I got this problem, where I need to capture get url variable pairs, but these are coming from an automatically created javascript and has this format:

page?custom zip=33021&custom city=boston... and so on...

 

If you notice the actual variable-names have spaces in it (custom zip, custom city; as opposed to normally named customzip, customcity) and when i try to capture them in php like this:

<?php echo $_GET['custom zip']; ?>

 

it doesnt do it... But if I manually change my url and join the variables like this: "customzip=33021" and change php accordingly, then it echoes it with no problem!

 

So I think is cause php doesnt like the actual variable to have spaces in it.. so how do I get to read it??

 

thanks, appreciate feedback...

Thanks Guys... adn Mchl, you are awesome! Your suggestion worked like a charm!!  I couldnt believe it was such a simple fix... simply making the space a hiphen did it beautifully. So does PHP automatically pick up spaces as underscores? does that happen only in this case when dealing with variables??

 

Thanks a lot!!

I think it will work only with GET and POST variables. It will also change other character that are invalid in variable names to underscore.

 

http://www.php.net/manual/en/language.variables.external.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.