|
Posted by Brent Baisley on 04/06/05 20:05
Making life groovy has been difficult since the 60's.
You want to have sprintf look at the contents of the variable instead
of the variable itself. Anytime you want to do something like this you
use the eval() function to evaluate the contents of the variable.
On Apr 6, 2005, at 12:46 PM, Duncan Hill wrote:
> On Wednesday 06 April 2005 16:40, Brent Baisley wrote:
>> For one, you are missing a right parenthesis ) in all of your
>> examples.
>> htmlentities( sprintf( $tmp[0], $s, ENT_QUOTES )
>
> Meh, syntax blip from the cut and paste.
>
>> Second, the string you are trying to format only has one variable
>> argument: $s.
>> Fred likes %1$s on his %2$s
>
> The source array in this case has two entries. My whole aim is to
> pass an
> array of n entries, unroll the array into a string and somehow
> interpolate
> the string into the sprintf call so that life is groovy. I realise $s
> looks
> like a single variable to PHP at that point sprintf() is called, and
> this is
> what I'm trying to work around - some way to get sprintf to realise
> that $s
> is actually two strings. Ie, I need a double level of interpolation
> on the
> $s value so that sprintf($tmp[0], $s) turns into sprintf(tmp[0],
> $array[0],
> $array[1]). I'm starting to get the feeling that this will be
> impossible.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
Navigation:
[Reply to this message]
|