Created
March 20, 2023 19:12
-
-
Save JRGGRoberto/6d10a056ca3f7effedd59d5619dcafd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<?php | |
$total = 6; | |
class Blocos { | |
public $pos; | |
public $cor; | |
function __construct($pos, $cor) { | |
$this->pos = $pos; | |
$this->cor = $cor; | |
} | |
} | |
$btnStatus = []; | |
array_push($btnStatus, new Blocos(3,'amarelo')); | |
array_push($btnStatus, new Blocos(3,'vermelho')); | |
array_push($btnStatus, new Blocos(2,'verde')); | |
array_push($btnStatus, new Blocos(1,'verde')); | |
echo '<pre>'; | |
print_r($btnStatus); | |
$btnS = []; | |
array_push($btnS, new Blocos(1,'cinza')); | |
array_push($btnS, new Blocos(2,'cinza')); | |
array_push($btnS, new Blocos(3,'cinza')); | |
array_push($btnS, new Blocos(4,'cinza')); | |
array_push($btnS, new Blocos(5,'cinza')); | |
array_push($btnS, new Blocos(6,'cinza')); | |
echo '<hr>'; | |
$btnStatus = array_reverse($btnStatus); | |
foreach($btnStatus as $btn){ | |
$btnS[$btn->pos -1] = $btn; | |
} | |
print_r($btnS); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Criando barra