janroald Posted March 23, 2007 Share Posted March 23, 2007 Not sure if this is the right forum-cathegory, but heck... //Examplified vars <input type="hidden" name="foo[]" value="bar1"> <input type="hidden" name="foo[foomatic][]" value="bar2"> <input type="hidden" name="foo[foomatic][]" value="bar3"> <input type="hidden" name="foo[foomatic][bar][]" value="bar4"> <input type="hidden" name="foo[foomatic][bar][]" value="bar5"> print_r Array ( [0] => bar1 [foomatic] => Array ( [0] => bar2 [1] => bar3 [bar] => Array ( [0] => bar4 [1] => bar5 ) ) ) Anyone knows when this feature was supported, or to what extent it is supported? Tested on FF/IE6 POST/GET Apache/PHP4 Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/ Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 I have no clue, does it work? If so what is the question? Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213584 Share on other sites More sharing options...
mjlogan Posted March 23, 2007 Share Posted March 23, 2007 Adding to the above, I'd use sessions. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213595 Share on other sites More sharing options...
janroald Posted March 23, 2007 Author Share Posted March 23, 2007 I have no clue, does it work? If so what is the question? Yes, it works in the context I mentioned in the start post. The question is really to what extent this works. In "old" times I used the [] way to transfer arrays, but I had no idea it worked with multidimensional ones too. Serializing data was, to my knowledge, the best way to transfer such data between pages, of course until sessions became an option, as "mjlogan" points out. This way one can access all form data through only one array variable. A huge workload has been lifted from me with this. What makes this work? Is it the browser, webserver or PHP? Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213668 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 It is the browser/HTML. Nothing fancy about that code simple HTML. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213708 Share on other sites More sharing options...
janroald Posted March 23, 2007 Author Share Posted March 23, 2007 Obviously, the webserver/scripting language does it's part too. Since an array variable is created in php from a form string. I'm sure this couldn't be done earlier at some point, since we used serializing to get it done. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213721 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 The webserver always has something to do with it, unless javascript can handle that type of data, than that is browser compatibility no? But yea, one way or the other this would NOT be possible period without some type of webserver and or language to power it. I think that goes without saying. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213729 Share on other sites More sharing options...
janroald Posted March 23, 2007 Author Share Posted March 23, 2007 Seems we kind of agree then. My question still stands. Does this way of passing multidimensional arrays work with all common webservers/browsers/languages? Is it a standardized way to pass multidimensional arrays? I'm googling and googling, but can't seem to find references to this anywhere. Just plain old [] to send an array. Cant seem to find examples of anyone doing name="foo[bar]", which will make the array assosiative, much less name="foo[bar][]" which will make it multidimensional. If this is now standard behaviour there are huge advantages to benefit from it. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213739 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 I would try it in Javascript, if you can pull the data in javascript it should work with any webserver out there. I know if it works in JS it will work with IIS and .NET. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213741 Share on other sites More sharing options...
janroald Posted March 23, 2007 Author Share Posted March 23, 2007 I'm not at all sure what you mean, or that you understand what I am writing here. foo[bar] is just text with brackets on client side. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213754 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 I understand what you mean. What I am saying is that if the input above can be accessed from Javascript, chances are most webhosts/languages support the multi-dimensional array return from an input field. That is why I said do a test with Javascript and see if Javascript can access the multi-dim array. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213763 Share on other sites More sharing options...
janroald Posted March 23, 2007 Author Share Posted March 23, 2007 Js cant access any array since there exists no array in the input fields, only pure text. Of course js can parse the text an build it's own array, but that proves nothing. Unless you can provide an example of what your intensions are, I can only understand that what you are trying to say makes no sense at all. In essence, the example I started with at first, will be sent to the server like this text string : ?foo%5B%5D=bar1&foo%5Bfoomatic%5D%5B%5D=bar2&foo%5Bfoomatic%5D%5B%5D=bar3&foo%5Bfoomatic%5D%5Bbar%5D%5B%5D=bar4&foo%5Bfoomatic%5D%5Bbar%5D%5B%5D=bar5 in php then : $_REQUEST[foo] now contains the array parsed from that text string. Whether js can access anything, has nothing to do with it at all. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213805 Share on other sites More sharing options...
per1os Posted March 23, 2007 Share Posted March 23, 2007 I will do some testing and see if I cannot create what I am thinking. Quote Link to comment https://forums.phpfreaks.com/topic/43985-passing-multidimensional-arrays-through-postget/#findComment-213810 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.