hi, i have a code that is repeated 3 times and i wonder if i better use a for loop or just leave it explicitly coded. here is the code:
or i should do this :
i don't know which is the best approach since the count is so little and the code inside the loop too.
if you have any suggestions let me know
Code:
$partsCopy = $this->_parts; $pos = array_search($newOrder[0], $this->_order); $this->_parts[0] = $partsCopy[$pos]; $pos = array_search($newOrder[1], $this->_order); $this->_parts[1] = $partsCopy[$pos]; $pos = array_search($newOrder[2], $this->_order); $this->_parts[2] = $partsCopy[$pos];
Code:
$partsCopy = $this->_parts;
for ($i = 0; $i < 3; $i++) {
$pos = array_search($newOrder[$i], $this->_order);
$this->_parts[$i] = $partsCopy[$pos];
}
if you have any suggestions let me know
Comment