hnh
hnh

Reputation: 13

parse RGB values from a string with php

Is there a way to parse multiple RGB values from a string? In what way should the colours be coded?

Eg.

$string = "foobar [rgb:123abc] some other text and another color: [rgb:ffeecc]"

I want [rgb:xxxxxx] to be replaced with something like <div style="background: #xxxxxx;">&nbsp;</div>

Upvotes: 1

Views: 372

Answers (1)

alex
alex

Reputation: 490233

You could use this regex to pick up the pattern...

/\[rgb:([0-9a-f]{6})\]/i

Upvotes: 3

Related Questions