Re: [PHP] sprintf and arrays.

2005-04-07 Thread Duncan Hill
On Wednesday 06 April 2005 18:05, Brent Baisley typed: > 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. Woot! $begin_string = 'htmlen

Re: [PHP] sprintf and arrays.

2005-04-06 Thread Richard Lynch
On Wed, April 6, 2005 4:23 am, Duncan Hill said: > I have a snippet of code that looks something like: > if (is_array($p_sub_values)) { > foreach ($p_sub_values as $i => $v) { > $p_sub_values_str[$i] = "'$v'"; > } > $s = join(',', $p_sub_values_str); > $r =

Re: [PHP] sprintf and arrays.

2005-04-06 Thread Brent Baisley
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

Re: [PHP] sprintf and arrays.

2005-04-06 Thread Duncan Hill
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 > argum

Re: [PHP] sprintf and arrays.

2005-04-06 Thread Brent Baisley
For one, you are missing a right parenthesis ) in all of your examples. htmlentities( sprintf( $tmp[0], $s, ENT_QUOTES ) Second, the string you are trying to format only has one variable argument: $s. Fred likes %1$s on his %2$s You have it numbered for ordering, but you are still ordering one

[PHP] sprintf and arrays.

2005-04-06 Thread Duncan Hill
I have a snippet of code that looks something like: if (is_array($p_sub_values)) { foreach ($p_sub_values as $i => $v) { $p_sub_values_str[$i] = "'$v'"; } $s = join(',', $p_sub_values_str); $r = htmlentities(sprintf($tmp[0], $s, ENT_QUOTES); } $tmp[0] in th