rtgx

Nahradenie markerov v texte

Tento kód pomocou PHP funkcie preg_replace nahradzuje značky v reťazci content podľa vzoru v poli patterns:

	/**
* Replace marks in content
*
* @param string $content: template code
* @param array $fields: replaced values
* @return string return: output text
*/
function parseMarks( $content, $fields ) {

$patterns = array(
0 => '/###CHEERID###/',
1 => '/###AMOUNT###/',
2 => '/###PAYMENT###/',
3 => '/###TIMING###/',
4 => '/###WRITETIME###/',
5 => '/###IP###/',
6 => '/###NAME###/',
7 => '/###EMAIL###/',
8 => '/###PHONE###/',
);
$replacements = array(
0 => $fields['cheerid'],
1 => $fields['amount'],
2 => $this->pi_getLL( 'tx_ext_table.value1.I.'.( $fields['payment'] - 1 ) ),
3 => $this->pi_getLL( 'tx_ext_table.value2 .I.'.( $fields['timing'] - 1 ) ),
4 => date( "d.m.Y, H:i", $fields['writetime'] ),
5 => $fields['ip'],
6 => $fields['name'],
7 => $fields['email'],
8 => $fields['phone'],
);
return preg_replace( $patterns, $replacements, $content );
}
 
Žiadne dokumenty ani odkazy k tejto stránke.