match, but not 2. The same logic applies (Web design service)
match, but not 2. The same logic applies to the [0-9]{4} statement: The only difference is that you are expecting four digits in the number, which indicate the year part of the date. So, in English, it means I want my string to start with a number with two digits, followed by a hyphen, and then another group of two digits, and then a hyphen, and finish with a four-digit number. if (!ereg( ([0-9]{2})-([0-9]{2})-([0-9]{4}) , $movie_release, $reldatepart) || empty( $movie_release )) { … } This is exactly what your regular expression says. If the string matches your condition, you will split it in three different chunks, each chunk delimited with the parentheses. This cutting is performed by the ereg() function. If the $movie_release string matches the pattern, ereg will cut the string into parts and then store each part as an element of the $reldatepart array. Be sure to read the PHP manual about regular expressions at www.php.net/regex and consult a few tutorials to understand the real power of using regular expressions. (You can find a good starting tutorial at www.phpbuilder.com/columns/dario19990616.php3.) If the user entered the date 02-03-2004, the array would be as follows: Array ( [0] => 02-03-2004 [1] => 02 [2] => 03 [3] => 2004 ) As you can see here, the first index holds the whole string, and each remaining index holds a cut-off part of the string, delimited by the parentheses. Now that you have the date in an understandable format, you can change it into a timestamp using the mktime() function, which allows you to create a timestamp from chunks of dates. It is also a very useful function to manipulate dates. $movie_release = mktime(0, 0, 0, $reldatepart[ 2 ], $reldatepart[ 1 ], $reldatepart[ 3 ]); This code stores a timestamp from the day, month, and year information fed to the system in the $movie_release variable. The format is int mktime (int hour, int minute, int second, int month, int day, int year). The returned value is the number of seconds between January 1, 1970, and the specified date. See documentation at www.php.net/mktime for additional information regarding optional parameters such as daylight saving flag. 249 Validating User Input
Check Tomcat Web Hosting services for best quality webspace to host your web application.