mardi 17 novembre 2020

checkbox print custom array E.g. if chooses Mon, Wed, Fri, Sat, Sun

I have checkbox like this:

enter image description here

E.g. if chooses Mon, Wed, Fri, Sat, Sun. return Mon, Wed, Fri - Sun

E.g. if chooses Sat, Sun. return Sat - Sun

E.g. if chooses Mon, Tue, Thu, Sat, Sun return Mon, Tue, Thu, Sat, Sun

How can I implement that? Is this possible?

$data = [
'get_day_for_route'            => (object)[
    'number_day'    => 1,
    'name_day'      => 'Mon'
],
(object)[
    'number_day'    => 2,
    'name_day'      => 'Tue'
],
(object)[
    'number_day'    => 5,
    'name_day'      => 'Fri'
],
(object)[
    'number_day'    => 6,
    'name_day'      => 'Sat'
],
(object)[
    'number_day'    => 7,
    'name_day'      => 'Sun'
 ],
 ];
 foreach($data as $result)
 {
  $day_result[] = $result->name_day;
 }
 echo implode(', ',$day_result);



Aucun commentaire:

Enregistrer un commentaire