|
Posted by greatprovider on 12/18/56 11:50
hah...that was the trick...thank you all...
one last question...now would anyone mind explaining me how "$1" works?
Rik wrote:
> greatprovider wrote:
> > the formulas are inputted into a database in the format:
> > "Na**3C**6H**5O**7*2H**20"
> > i query the database and pass the list of unformated formulas through
> > this function in a loop.
> >
> > function format_replace($formula) {
> > $search = "/(\*{2}[\d]+)/";
> > $replace = "<sub>\l</sub>";
> > $formatted = preg_replace( $search, $replace, $formula);
> > return $formatted;
> > }
> > the result i get for this is: Na\lC\lH\lO\l*2H\l (where "\l" is
> > subscripted).
>
> Euhm, I think i found the problem after numerous, all working, examples:
>
> Use the NUMBER 1, it's hard in certain fonts to see the difference, but you
> write 'l', not'1'.....
>
>
> $search = '/\*{2}([\d]+)/';
> $replace = '<sub>$1</sub>';
>
> Using $N instead of \N is preferred.
> Single quotes so PHP won't try to match a '$' to an existing variable.
>
> Grtz,
> --
> Rik Wasmus
Navigation:
[Reply to this message]
|