please i want to make a nice php function that convert my html input values into a unixTime stamp and than insert to my mysql table field
This is my HTML code
$names = array();
<input type="text" name="name1_dd"/>
<input type="text" name="name1_mm"/>
<input type="text" name="name1_yy"/>
<input type="text" name="name2_dd"/>
<input type="text" name="name2_mm"/>
<input type="text" name="name2_yy"/>
<input type="text" name="name3_dd"/>
<input type="text" name="name3_mm"/>
<input type="text" name="name3_yy"/>
<input type="text" name="name4_dd"/>
<input type="text" name="name4_mm"/>
<input type="text" name="name4_yy"/>
as you see my html form contain a lots of nameX_ Fields and i want to write a function that merge each 3 fields i talk about ( x_dd x_mm x_yy ) and put them in $names array each 3 fields in a key for example : $a[0] contain strtotime(dd.mm.yy)
thank you
First, use an array for your inputs, then just loop through them and implode
:
<input type="text" name="name[1][d]"/>
<input type="text" name="name[1][m]"/>
<input type="text" name="name[1][y]"/>
foreach($_POST['name'] as $values) {
$result[] = implode('.', $values);
//or build like this
//$result[] = $values['d'] . '.' . $values['m'] . '.' . $values['y'];
}
print_r($result);
You would be better off using a date picker.