Questions tagged [printf]

The printf function is widely used for formatted output across various programming languages. C and several other languages also have a range of similar functions that serve the same purpose. Use this tag only if your question specifically involves printf or its related functions.

Enhancing a PHP loop with preg_replace or sprintf to substitute MySQL data with tags embedded in a string in the ##tag## format

Let's say I have received an array from a database containing: $row = array("percent" => "33%", "name" => "30 Cups", "price" => "$16"); In addition, let's assume there is a string like the following: $string = "Take ##percent## off ou ...

PHP prints the digits using the format %s

I have always wondered why we can't just use printf %s for all types of variables since it seems to work. I've been using it this way for many years. The manual recommends using %d for integers and decimals, but what is the actual difference between usi ...