نوب
2 سال پیش توسط نوب مطرح شد
1 پاسخ

کم کردن حجم کد

سلام
راهی هست به نظرتون که حجم این کد کمتر بشه ؟

$this->startDay1Time = $this->classRoom->startDay1Time;
        $this->startDay2Time = $this->classRoom->startDay2Time;
        $this->startDay3Time = $this->classRoom->startDay3Time;
        $this->startDay4Time = $this->classRoom->startDay4Time;
        $this->startDay5Time = $this->classRoom->startDay5Time;
        $this->startDay6Time = $this->classRoom->startDay6Time;
        $this->startDay7Time = $this->classRoom->startDay7Time;
        $this->endDay1Time = $this->classRoom->endDay1Time;
        $this->endDay2Time = $this->classRoom->endDay2Time;
        $this->endDay3Time = $this->classRoom->endDay3Time;
        $this->endDay4Time = $this->classRoom->endDay4Time;
        $this->endDay5Time = $this->classRoom->endDay5Time;
        $this->endDay6Time = $this->classRoom->endDay6Time;
        $this->endDay7Time = $this->classRoom->endDay7Time;

ثبت پرسش جدید
Parastoo Ebrahimi
تخصص : front-end developer
@parastooebrahimi 2 سال پیش مطرح شد
-1
for ($i = 1; $i <= 7; $i++) {
    $this->startDay{$i}Time = $this->classRoom->{"startDay{$i}Time"};
    $this->endDay{$i}Time = $this->classRoom->{"endDay{$i}Time"};
}

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام