[FX.php List] [OFF] Replace parts of a string w/ non-string
elements?
Joel Shapiro
jsfmp at earthlink.net
Thu Aug 21 15:35:01 MDT 2008
hmm... I could create an auto-enter-calc or calc field in FMP.
That'd probably be easiest. But is there a way to do this just in PHP?
-Joel
On Aug 21, 2008, at 2:20 PM, Joel Shapiro wrote:
> Hi all
>
> I've got a field in which FileMaker users can enter various field
> names like merge fields, such as:
> "Hello <<nameFirst>> ..."
>
> In the PHP, I'd like to be able to automatically replace all
> instances of "<<fieldName>>" from within that field with "
> $queryData['fieldName'] ", such as:
> "Hello ' . $queryData['fieldName'] . ' ..."
> (or even "Hello $queryData['fieldName'] ..." with just double-quotes)
>
> Is there any PHP function that can do this?
>
> The problem seems to be stepping out of and back into a string.
> str_replace() just makes the "$queryData" into part of the string,
> when I really want to step *out of* the string.
>
> For the last project there weren't many possible <<mergeFields>>,
> so I worked around this by hard-coding two arrays for use within a
> str_replace() function, as such:
>
> $from = array(
> '<<fieldName1>>',
> '<<fieldName2>>'
> );
>
> $to = array(
> $queryData['fieldName1'],
> $queryData['fieldName2']
> );
>
> But still, I'm curious. Is there some other way to do this?
>
> TIA,
> -Joel
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list