<?php

	$rgba = array("r" => 0, "g" => 0, "b" => 0, "a" => 1);
	$string = "246, 24, 35, 0.8";
	$i = 0;
	preg_match_all('/[0-9.]+/', $string, $color);
	
	foreach ($rgba as $key => $value){
	  $rgba[$key] = $color[0][$i++] ?: 1;
	}
	
	print_r($rgba);

?>