foreach ($row as $key => $value) {
$this->outline->{$key} = $value;
}
How to refactor a large number of array keys to object properties in a few lines of code?
-
18-06-2023 - |
문제
I have code that looks like this (full code has 47 lines):
$this->outline->value = $row['value'];
$this->outline->some_value = $row['some_value'];
$this->outline->specs = $row['specs'];
$this->outline->second_marker = $row['second_marker'];
$this->outline->holes = $row['holes'];
How can I make this smaller while maintaining same functionality?
해결책
제휴하지 않습니다 StackOverflow