<select name="date">
<option value="20091101000000 20091131000000">Nov 09</option>
</select>
$_POST['date']
Considering if I want to extract the value "20091101000000" and "20091131000000" separately and store into TWO different variables, how do I do it?
Thank you in advance. I'm new to PHP. Hope to learn more from you guys
Extracting data in variable
Moderator: General Moderators
Re: Extracting data in variable
Hi Friend,
Use some character between 2 numbers ex. (20091101000000-20091131000000). Now explode this number by that character, you will get 2 array elements as "20091101000000" and "20091131000000".
Use some character between 2 numbers ex. (20091101000000-20091131000000). Now explode this number by that character, you will get 2 array elements as "20091101000000" and "20091131000000".
Re: Extracting data in variable
It's very easy. You should use the explode() function.
But more useful variant it use both function: list() and explode():
Code: Select all
<?
$array = explode(' ', $_POST['data']);
$first = $array[0];
$second = $array[1];
?>
Code: Select all
<?
list($first, $second) = explode(' ', $_POST['data']);
?>
Re: Extracting data in variable
Thank you guys! I really appreciated it! 