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

Bernhard Kraft kraftb at kraftb.at
Sun Jun 19 15:36:04 CEST 2005


Georg Ringer wrote:
> Hello,
> 
> I'm wondering how this works and how I can use this in my own extension:
> "pi_list_browseresults_displays" => "Zitat(e) ###SPAN_BEGIN###%s bis
> %s</span> von ###SPAN_BEGIN###%s</span>",
> =>> I would see:  Zitat(e) 1 bis 15 von 176
> 
> Now I also want to use this and I don't know how.
> Who can help me?
> 
> many thanks in advance (again)
> Georg

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)

greets,
Bernhard




More information about the TYPO3-dev mailing list