I need some help with a formatting function. I need to be able to take the input (function argument) and format the string to something else. Here’s my options:
7am7pm
10am10pm
OFF
So, depending on what is selected, I want the regex to meet the following output criteria:
7am-7pm
10am-10pm
OFF
In other words, I need a hyphen inserted between the times and the original could be either [0-9]{2} or [0-9]{1}, so I’m guessing something like [0-9]{1,2}, but I’m unsure how to create the function and use it in PHP.
Try
Demo: http://codepad.org/BBwW4eEE