mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Documentation for str_pad().
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@27883 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
a58934a426
commit
2296ac3de9
1 changed files with 56 additions and 0 deletions
|
@ -1902,6 +1902,62 @@ if (!strcasecmp ($var1, $var2)) {
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.str-pad">
|
||||
<refnamediv>
|
||||
<refname>str_pad</refname>
|
||||
<refpurpose>Pad a string to a certain length with another string</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>str_pad</function></funcdef>
|
||||
<paramdef>string <parameter>input</parameter></paramdef>
|
||||
<paramdef>int <parameter>pad_length</parameter></paramdef>
|
||||
<paramdef>string
|
||||
<parameter><optional>pad_string</optional></parameter></paramdef>
|
||||
<paramdef>int
|
||||
<parameter><optional>pad_type</optional></parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
This functions pads the <parameter>input</parameter> string on
|
||||
the left, the right, or both sides to the specifed padding
|
||||
length. If the optional argument
|
||||
<parameter>pad_string</parameter> is not supplied, the
|
||||
<parameter>input</parameter> is padded with spaces, otherwise it
|
||||
is padded with characters from <parameter>pad_string</parameter>
|
||||
up to the limit.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Optional argument <parameter>pad_type</parameter> can be
|
||||
STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH. If
|
||||
<parameter>pad_type</parameter> is not specified it is assumed to
|
||||
be STR_PAD_RIGHT.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If the value of <parameter>pad_length</parameter> is negative or
|
||||
less than the length of the input string, no padding takes
|
||||
place.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title><function>str_pad</function> example</title>
|
||||
<programlisting role="php">
|
||||
$input = "Alien";
|
||||
print str_pad($input, 10); // produces "Alien "
|
||||
print str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien"
|
||||
print str_pad($input, 10, "_", STR_PAD_BOTH); // produces "__Alien___"
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.strpos">
|
||||
<refnamediv>
|
||||
<refname>strpos</refname>
|
||||
|
|
Loading…
Reference in a new issue