I have this tag on an HTML code:
text html [button link="google.com" color="#fff" text="this text here"] rest of html
I wish i could have the parameters of this "button code" in a PHP variable, but have no idea how because of Regex.
I tried using preg_match_all but no success. Like this one:
preg_match_all('/color=(\w*)/i', $text, $color);
Thanks!
if (preg_match_all('~(?:\G(?!^)|\[button)\s+(\w+)="([^"]*)"~', $text, $matches)) { print_r(array_combine($matches[1], $matches[2]));}- see 3v4l.org/qMqXh\w*won't match the#character in the color attribute. Or the quotes around the attribute value.