So, I have a script that I need to take a date (currently as a string), and split it up to enter them in forms... example:
Date: May 20, 2009
I need it to show up as:
<INPUT TYPE="TEXT" VALUE="MAY"> <INPUT TYPE="TEXT" VALUE="20"> <INPUT TYPE="TEXT" VALUE="2009">
I've looked up preg_match, which is what I was recommended, but I have no idea what the sample code is supposed to look like?
halp!
How to take a string and make it fields?
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: How to take a string and make it fields?
Assuming the text "Date: " is in there. If not then forgo the str_replace():
Code: Select all
$date = strtotime(str_replace('Date: ', '', 'Date: May 20, 2009'));
$month = date('F', $date);
$day = date('j', $date);
$year = date('Y', $date);mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: How to take a string and make it fields?
AbraCadaver wrote:Assuming the text "Date: " is in there. If not then forgo the str_replace():
Code: Select all
$date = strtotime(str_replace('Date: ', '', 'Date: May 20, 2009')); $month = date('F', $date); $day = date('j', $date); $year = date('Y', $date);
this worked PERFECTLY, THANK YOU!
Now, how do I buy you an e-beer?