Mudsaf Posted August 6, 2013 Share Posted August 6, 2013 (edited) Im wondering is there anyway to run browser address get query with like this. http://mypage.com?var=1&2&3<?php$_GET['var'][0]; //returns 1 and so on or something similar without repeating var at address bar?> Edited August 6, 2013 by Mudsaf Link to comment Share on other sites More sharing options...
thescientist Posted August 6, 2013 Share Posted August 6, 2013 (edited) no, a query string is just that, a string. If you have a delimited list as a value, as in the case for var, you would need to explode the string first. http://php.net/manual/en/function.explode.php <?php $vars = explode('&', $_GET['var']); echo $vars[0]; //1echo $vars[1]; //2echo $vars[2]; //3?> Edited August 6, 2013 by thescientist Link to comment Share on other sites More sharing options...
justsomeguy Posted August 6, 2013 Share Posted August 6, 2013 Note that & has a special meaning in the URL, it separates key/value pairs. If that's the character you want to use as a separator then you need to encode it. Otherwise, that will create $_GET['var'], and set it to 0, $_GET['1'] and it will be empty, and $_GET['2'] and it will be empty. Link to comment Share on other sites More sharing options...
thescientist Posted August 6, 2013 Share Posted August 6, 2013 oh right. yes, completely over looked that. Link to comment Share on other sites More sharing options...
Ingolme Posted August 6, 2013 Share Posted August 6, 2013 I believe this works: ?var[]=1&var[]=2&var[]=3 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now