printf

Output a formatted string.

PHP

$format = 'There are %d monkeys in the %s';
printf($format, 5, 'tree');
// => There are 5 monkeys in the tree

Ruby

my_string = 'There are %d monkeys in the %s';
printf(my_string, 5, 'tree');
# => There are 5 monkeys in the tree
By | 2009-04-24T13:35:51+00:00 April 23rd, 2009|Categories: PHP, Ruby|Tags: , , , |1 Comment

About the Author:

One Comment

  1. Almazko July 19, 2011 at 7:44 pm

    RUBY:

    puts ‘There are %d monkeys in the %s’ % [5, ‘tree’]

Comments are closed.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.