My html code :
<form method="post">
<input id="user1" value="user1" name="invite[]" type="checkbox">
<input id="user2" value="user2" name="invite[]" type="checkbox">
<input type="submit">
</form>
PHP code is :
if(isset($_POST['invite'])){
if (is_array($_POST['invite'])) {
foreach($_POST['invite'] as $value){
$list = array($value);
$fh = print_r($list, true);
}
}
}
And the print_r output is :
Array ( [0] => user1 )
Array ( [0] => user2 )
My required output is: Array ( [0] => user1 [1] => user2 )
I'm working from the last 36 hours and googled but no luck. What is the error in my code or is there any better way to achieve checkbox values into an array(the actual values in my code are email id"s)
Thanks in advance