ok here is one for you
a d20 math parser...
in roleplaying games based on dice rolling you run across statements like
1d20+(1d6*4)
mean roll a 20 sided die rand(1,20), add it to ( a 6 sided die rand(1,6) multiplied by 4 )
the d is really just and new operator meaning rand(1,RIGHT) repeated LEFT times
i would like to take the a string like above, and have php evaluate this into a single integer...
but im not really sure how to get started on making a string parser in in php
anyone done one before...
my initial thought was to step char by char through using $string{$x} looking for parens, kina like a sax xml parser, and build a tree of the statement then evaluate each node starting with the leaves up.
is there a quicker way anyone has seen using native php functions