I have a bunch of checkboxes with the names like the following:
q1_week1_monday
How can i split these strings into 3 different variables, for example
$quarter = q1;
$week = 1;
$day = monday;
Thanks
I have a bunch of checkboxes with the names like the following:
q1_week1_monday
How can i split these strings into 3 different variables, for example
$quarter = q1;
$week = 1;
$day = monday;
Thanks
Use explode()
to split the string and the list
construct to assign the parts to the variables. Afterwards, get rid of the week-prefix, using regexp.
list ($quarter, $week, $day) = explode("_", "q1_week1_monday")
$week = preg_replace("#week(\d+)#", "$1", $week);