php – vprintf

Hi, vprintf function is used to format an out put of a string.

Here is the good example:

<?php

$pc = array(1, ‘laptop’,1, ‘printer’, 3, ‘disks ‘, 2, ‘floppys’);

vprintf(“I have %d %s, %d %s, %d %s and %d %s.”, $fruits);

?>

 
Output:

I have 1 laptop, 1 printer, 3 disks and 2 floppys.

You can use also %1$s or %3$s to select the first or third string.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: