Skip to content

Instantly share code, notes, and snippets.

@SalocinDotTEN
Created October 22, 2018 09:16
Show Gist options
  • Save SalocinDotTEN/82993606824ae5f41c44cc77f490b025 to your computer and use it in GitHub Desktop.
Save SalocinDotTEN/82993606824ae5f41c44cc77f490b025 to your computer and use it in GitHub Desktop.
Get a colour code based on inputted integer.
<?php
$colours = array('#FDA...', '#83B...', '#53A...', '#BE3...', '#A24...');
echo $colours[$integerParam % count($colours) - 1];
//Expected output is the corresponding HEX colour based on the inputted $integerParam.
//Advantage is that the array can be added or shortened and it will work.
//Redacted colour code due to company restrictions.
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment