Skip to content

Instantly share code, notes, and snippets.

@JRGGRoberto
Created March 20, 2023 19:12
Show Gist options
  • Save JRGGRoberto/6d10a056ca3f7effedd59d5619dcafd5 to your computer and use it in GitHub Desktop.
Save JRGGRoberto/6d10a056ca3f7effedd59d5619dcafd5 to your computer and use it in GitHub Desktop.
<!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>
@JRGGRoberto
Copy link
Author

Criando barra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment