使用php分离rgba颜色值的红、绿、蓝值

使用php分离rgba颜色值的红、绿、蓝值,php,Php,我是这个格式的rgba(205,31,31,1)的hv rgba值,我想分离每个红色、绿色、蓝色和alpha值,以便进一步处理如何使用php实现它;所以输出看起来像 red = 205 green = 31 blue = 31 alpha =1 将preg_match与正则表达式一起使用: $string = "RGBA(205,31,31,1)"; if(preg_match("/RGBA\((\d+),(\d+),(\d+),(\d+)\)/", $string, $matches)) {

我是这个格式的rgba(205,31,31,1)的hv rgba值,我想分离每个红色、绿色、蓝色和alpha值,以便进一步处理如何使用php实现它;所以输出看起来像

red = 205
green = 31
blue = 31
alpha =1

preg_match
与正则表达式一起使用:

$string = "RGBA(205,31,31,1)";
if(preg_match("/RGBA\((\d+),(\d+),(\d+),(\d+)\)/", $string, $matches)) {
  // $matches[0] contains the complete matched value, so we can ignore that
  echo "red = " . $matches[1] . "\n";
  echo "green = " . $matches[2] . "\n";
  echo "blue = " . $matches[3] . "\n";
  echo "alpha = " . $matches[4] . "\n";
}

preg_match
与正则表达式一起使用:

$string = "RGBA(205,31,31,1)";
if(preg_match("/RGBA\((\d+),(\d+),(\d+),(\d+)\)/", $string, $matches)) {
  // $matches[0] contains the complete matched value, so we can ignore that
  echo "red = " . $matches[1] . "\n";
  echo "green = " . $matches[2] . "\n";
  echo "blue = " . $matches[3] . "\n";
  echo "alpha = " . $matches[4] . "\n";
}

preg_match
与正则表达式一起使用:

$string = "RGBA(205,31,31,1)";
if(preg_match("/RGBA\((\d+),(\d+),(\d+),(\d+)\)/", $string, $matches)) {
  // $matches[0] contains the complete matched value, so we can ignore that
  echo "red = " . $matches[1] . "\n";
  echo "green = " . $matches[2] . "\n";
  echo "blue = " . $matches[3] . "\n";
  echo "alpha = " . $matches[4] . "\n";
}

preg_match
与正则表达式一起使用:

$string = "RGBA(205,31,31,1)";
if(preg_match("/RGBA\((\d+),(\d+),(\d+),(\d+)\)/", $string, $matches)) {
  // $matches[0] contains the complete matched value, so we can ignore that
  echo "red = " . $matches[1] . "\n";
  echo "green = " . $matches[2] . "\n";
  echo "blue = " . $matches[3] . "\n";
  echo "alpha = " . $matches[4] . "\n";
}
可能的重复可能的重复可能的重复可能的重复