0

I have the following code where MODE is a variable. Its value should be a method of jQuery's tinycolor liberary.

$cor = tinycolor($cor).mode(z).toString();

I'd like to call that method on that line so, for instance, when mode = 'lighten' $cor would be

$cor = tinycolor($cor).lighten(z).toString();

Is there a way of doing it this way?

Thanks!

Souljacker
  • 595
  • 6
  • 23

1 Answers1

3

Use bracket notation

$cor = tinycolor($cor)[mode](z).toString();
adeneo
  • 312,895
  • 29
  • 395
  • 388