By: Mick@el
Date: 2007-05-15
Time: 12:44
|
Using built-in PHP functions with the onformat parameter
If you want to use some PHP Functions (like stripslashes or str_replace) with the "onformat" field parameter, you can insert these functions in your PHP Code :
function PhpFunc($FieldName, &$CurrVal, &$CurrPrm)
{
$fct = $CurrPrm['fct'];
if (function_exists($fct))
{
$prms = Array();
$i = 1;
while (isset($CurrPrm['prm' . $i]))
{
$prms[] = $CurrPrm['prm' . $i];
$i++;
}
$CurrVal = call_user_func_array($fct, $prms);
}
}
function SinglePhpFunc($FieldName, &$CurrVal, &$CurrPrm)
{
$fct = $CurrPrm['fct'];
if (function_exists($fct))
{
$CurrVal = $fct($CurrVal);
}
} |
Examples :
[myfield; onformat=SinglePhpFunc; fct=stripslashes] |
[myfield; onformat=PhpFunc; fct=str_replace; prm1=Hello; prm2=Hi; prm3=[val]] |
|