This question already has an answer here:
I am trying to use elseif in php to compare string and push position in array but I can't figure out what I am doing wrong. Here's what I have done.
<?php
$inp = "Monday";
$pos_su = 0;
$pos_mo = 0;
$pos_tue = 0;
$pos_wed = 0;
$pos_thu = 0;
$pos_fri = 0;
$schedules[] = [
'Day' => $inp,
'Position' => ($inp === 'Sunday') ? $pos_su++ :
($inp === 'Monday') ? $pos_mo++ :
($inp === 'Tuesday') ? $pos_tu++ :
($inp === 'Wednesday') ? $pos_wed++ :
($inp === 'Thursday') ? $pos_thu++ :
($inp === 'Friday') ? $pos_fri++ : 0,
];
var_dump($schedules);
var_dump($pos_mo);
Aucun commentaire:
Enregistrer un commentaire