TripleDES Posted June 15, 2007 Share Posted June 15, 2007 I can't seem to get the following to work: $contents = 'Replace me %1$s and %2$s'; $args = '$parts[0],$parts[1]'; printf($contents, $args); However, no issues if I do: printf($contents, $parts[0],$parts[1]); Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/ Share on other sites More sharing options...
redarrow Posted June 15, 2007 Share Posted June 15, 2007 Reed this please ok. http://uk2.php.net/print_f Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/#findComment-275054 Share on other sites More sharing options...
Foser Posted June 15, 2007 Share Posted June 15, 2007 What are your "Part" array assigned to? Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/#findComment-275055 Share on other sites More sharing options...
redarrow Posted June 15, 2007 Share Posted June 15, 2007 sorry want to replace somethink use. [code] <?php $x=str_replace("this_word","to_this_word",$from_this_varable); echo $x; ?> <?php $contents = 'Replace me %1$s and %2$s'; $args = '$parts[0],$parts[1]'; $x=explode($args); printf($contents, $x); ?> ps. use explode/implode your first post. i might be wrong theo sorry?[/code] Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/#findComment-275057 Share on other sites More sharing options...
TripleDES Posted June 15, 2007 Author Share Posted June 15, 2007 Reed this please ok. http://uk2.php.net/print_f I did, but it wasn't much help. What are your "Part" array assigned to? Not quite sure what you're asking. Anyway, I see where it's hanging up. It doesn't seem to like me feeding multiple arguments separated by commas. If I do $a = $parts[0]; $b = $parts[1]; then printf($contents, $a, $b) it works.... but $args = $parts[0], $parts[1]; breaks Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/#findComment-275058 Share on other sites More sharing options...
TripleDES Posted June 15, 2007 Author Share Posted June 15, 2007 Okay, this worked! vprintf($cfgcontents, $parts); Quote Link to comment https://forums.phpfreaks.com/topic/55664-solved-printf-not-accepting-variables-for-arguments/#findComment-275059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.