Re: sprintf and arrays.

From: Date: Wed, 06 Apr 2005 16:46:54 +0000
Subject: Re: sprintf and arrays.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-212445@lists.php.net to get a copy of this message
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.

« previous php.general (#212445) next »