I want to convert back and forth between RGBA-formated HEX colors (like0xFF0000FF) and RGB-formated HEX colors (like 0xFF0000) in PHP.
0xFF0000FF
0xFF0000
How
These two functions will do what you need:
function rgbaToRgb ($rgba) { return substr($rgba, 0, -2); } function rgbToRgba ($rgb) { return $rgb . "FF"; }
The first one simply removes the last two characters, whilst the second one simply appends FF.
FF