monkeytooth Posted February 10, 2009 Share Posted February 10, 2009 Ok I need to make a single var passed via URL look like an array. Is there anyway to do that. Im trying to avoid having to reinvent the wheel on a specific section of a site im working on. Right now I have a form and the builds an array to be passed on via $_POST which that works fine. However the specific page im working on is a key to editing DB entries for the site. Sometimes theres just a need to only edit/remove one entry. Which I want to pass onto this page via URL and then use $_GET to snag the var I want to use. Problem is with the loop im running it only recognizes input as array. So with that, how can i take that single $_GET var and turn it into an array? Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/144659-solved-make-array-from-_get/ Share on other sites More sharing options...
kenrbnsn Posted February 10, 2009 Share Posted February 10, 2009 Something like this should work: <?php $var = (is_array($_GET['var']))?$_GET['var']:array($_GET['var']); ?> unless I misunderstood what you're trying to do. Ken Quote Link to comment https://forums.phpfreaks.com/topic/144659-solved-make-array-from-_get/#findComment-759067 Share on other sites More sharing options...
premiso Posted February 10, 2009 Share Posted February 10, 2009 If ken's answer is not what you are looking for, you can look into serialize and unserialize, but re-reading the question, I think ken hit the nail on the header. Quote Link to comment https://forums.phpfreaks.com/topic/144659-solved-make-array-from-_get/#findComment-759072 Share on other sites More sharing options...
monkeytooth Posted February 10, 2009 Author Share Posted February 10, 2009 That's it exactly, thank you.. I was definitely approaching that Bass Ackwards.. with how i was attempting to make an array out of the $_GET Quote Link to comment https://forums.phpfreaks.com/topic/144659-solved-make-array-from-_get/#findComment-759083 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.