Form Input name with square brackets not an array in PHP
578
I have a form like this:
<form action='http://zzz.com' method='post'>
<input name='fruit[1]' value='apple' />
<input name='fruit[2]' value='banana' />
</form>
on the server side this should be an array.
assert( $_POST['fruit'] === array(1=>'apple', 2=>'banana') );
In my case it is an empty string !!??!!
assert( $_POST['fruit'] === '' );
I have no idea what the problem is - never seen this before. Anyone can help plz?
PHP 5.5.12
Answer
Solution:
use like this...
after submitting ok button it will show you complete array