2

For example, I have a string "MThF". This stands for Monday (M), Thursday (Th) and Friday (F). I want to be able to split this string in PHP, but unfortunately, the string won't come with any delimiters. How do I solve this problem? I tried doing preg_replace but to no avail.

Here is a sample code I tried:

$keywords = preg_replace("/([a-zA-Z])([A-Z])/", "//", "MThF");
print_r($keywords);

This should work with all days of the week btw. M is Monday, T is Tuesday, W Wednesday, Th Thursday, F Friday, Sat is Saturday and Sun is Sunday.

Any help would be much appreciated. Thank you!

Lewey Jimoya
  • 105
  • 8

0 Answers0