I have 2 dropdowns. Whatever I have to select from first dropdown and second dropdown both value I have to display on the screen. I mean I have to display in the same column with a comma(,). Would you help me in this?
<form action="#" method="post">
<select name="ab[]">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<select name="ab[]">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
<input type="submit" name="submit" value="submit">
</form>
if(isset($_POST['submit']))
{
$ab=$_POST['ab'];
$a=array($ab);
print_r($a);// I am able to display value here but implode is not working.
$b = implode(',',$a);
print_r($b);
}
you don't need this
$a=array($ab); //remove this line
If you need that for any other purpose then change your code to this
$b = implode(',',$a[0]);