[pmwiki-devel] $12.50 -> .50 var problem

The Editor editor at fast.st
Mon Apr 9 18:08:23 CDT 2007


On 4/9/07, christian.ridderstrom at gmail.com
<christian.ridderstrom at gmail.com> wrote:
> On Mon, 9 Apr 2007, The Editor wrote:
>
> > The following is causing me huge problems.  Been working on it for
> > hours--and seem to have finally narrowed it down to here...
> >
> > if (strpos($newpage[text], "(:$ff: ") == true) $newpage['text'] =  preg_replace(
> >           '/\\(:'.$ff.': (.*?):\\)/s',  "(:$ff: $v:)",  $newpage['text'], 1);
> >
> > It's part of a routine that checks to tell if a certain (hidden) text
> > variable exists and if it does, it replaces the current value with the
> > new value ($v).
> >
> > All works fine generally--except when $v has a $ in it it thinks its a
> > variable that doesn't exist.  So $12.50 gets changed to .50.  And that
> > throws me off.
>
> Not sure if it'll help, but try
>
>   if (strpos($newpage[text], "(:$ff: ") == true)
>     $newpage['text'] =
>        preg_replace('/\\(:'.$ff.': (.*?):\\)/s',  "(:$ff: ".$v.":)",
>                     $newpage['text'], 1);
>
> /C


Thanks Christian, I did try that early on, with no luck--in fact that
was my initial code.  Can't really understand why it is doing what it
is...

I ended up doing a temporary string replacement of $ to -$- and then
string replace it back, but there ought to be a 'right' way to do
this...  Thanks again!

Cheers.
Dan



More information about the pmwiki-devel mailing list