On Fri, Mar 16, 2007 at 10:22:47AM -0400, The Editor wrote:
> In order to help with downward compatibility on ZAPbeta 2007-03, I'm
> trying to set up a pattern that will match something like this:
> 
> Field="Value"
> 
> if the normal PTV function finds nothing.  Given the field name is
> $var, I'd like to be able to do something like:
> 
>       $var = PageTextVar($page, $var);
>       if ($var == '') {
>               $page = ReadPage($page);
>               $var = preg_replace('/'$var'\\=\\"(.*?)\\"/s',"$1", 
> $page['text']);
>               }
> 
> It seems to be close to matching the pattern cause it does something
> strange on the page text, but I don't want to change the page text, I
> want to simply extract the $var value from the page and assign it to
> $var.  Can someone explain what function to use to do this?  TIA!

Use preg_match():

    $val = PageTextVar($page, $var);
    if ($val == '' && preg_match("/$var=\"(.*?)\"/s', $page['text'], $match))
      $val = $match[1];

Pm

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to