[Typo3-dev] locallang-entry with variable in between

Robert Lemke robert at typo3.org
Tue Jun 21 00:14:00 CEST 2005


Bernhard Kraft wrote:

> If you do:
> 
> $result = sprintf('Variable 1: %s .... Variable 2: %s', $var1, $var2);
> 
> Then the contents of the occurencies of %s will be replaced by the vars
> after the string in the order they appear ...
> 
> you can achieve the same with
> $result = str_replace('%s', $var1, $origStr);
> 
> Normally you should choose sprintf if you replace %s and str_replace for
> all others. (sprintf is some kinf of C relict for people who don't know
> about str_replace)

That's the way we do it currently and I don't have a better idea, but be
aware that there might be problems if the order must be different in other
languages:

Some languages might write "of 8: 4" instead of "4 of 8".

-- 
robert




More information about the TYPO3-dev mailing list