$months="Jan, Feb, Mar, Apr, May, Jun, July, Aug, Sep, Oct, Nov,Dec";
We can break strings to form arrays. We can break by using a pattern or by regular expression. This way we can break strings to create array of string. Here is the syntax.
array split (string pattern, string string [, int limit])
We can specify ( option )the limit of breaking required.
One of the main uses is creating a month date and year from the data entered by the users. Users will enter date in one input box in mm/dd/yy format. We will use this string and break it into three parts storing month, date and year in three different variables for further processing. Here is the code how this works.
We will get the value from the form and the date entered by the user is available in variable $mytime. Where $mytime="05/13/05";
$arr=split("/",$mytime); // splitting the array
$mm=$arr; // first element of the array is month
$dd=$arr; // second element is date
$yy=$arr; // third element is year