I have ImageMagick histogram color info in string, I want to parse string using php preg_match() function, sorry I have not more knowledge about Regular Expression.
<?php
$str = "588: ( 99, 75, 52) #634B34 srgb(99,75,52)";
preg_match('/(?P<colors>\d+\:)/', $str, $matches);
print_r($matches);
?>
Expected output
Array
(
[colors] => 588,
[red] => 99,
[green] => 75,
[blue] => 52
)
How do I get the desired output, or is there another way to get colors and density?