Ever wanted to split a string into array by reqular expression? For example, you can use this function to parse a spring of date into month, day, and year that’s delimited with slashes, dots, or hyphens. Here’s a basic way to do it.
- For instance, I have captured today’s date as the following;
- To do the splitting, you will need to use these list and split function;
- The $month, $day, and $year variables are used to store the splitted date. The ‘/’ is the delimiter that will act as a boundary to split the date. The delimiters may be slash, dot, or hyphen. But you may also use them all at the same time too;
- And as the result, you will get the following;
$day = 31
$year = 2010
- And of course you may retrieve those variable by using this piece of code;
<?php echo $day?>
<?php echo $year?>
- And oh, take a note that some delimeters will need some exception. For example… symbol “?” and “|” alone will not work, because they are operators in PHP. So if you want to use those symbols as delimiter you must excape it with a back slash, “\|“. Your code should look something like this;
ajwa . Naj . Wawa . 26 . 











