Home > php教程 > php手册 > str_pad() 将字符串填充成指定长度的字符串

str_pad() 将字符串填充成指定长度的字符串

WBOY
Release: 2016-06-13 11:37:39
Original
1026 people have browsed it

/**
* 将字符串填充成指定长度的字符串(多字节安全)
* @param string $str 指定被填充的字符串
* @param int $len 指定被填充的字符串的长度,如果值为负数或小于字符串的长度则不填充
* @param string $pad_str 要填充的字符串
* @param int $pad_type 指定填充的方向STR_PAD_RIGHT,STR_PAD_LEFT或STR_PAD_BOTH
* @return string
*/

// string str_pad(string $str, int $len, string $pad_str, string $pad_type);

echo str_pad($result2[0],6,"0",STR_PAD_LEFT);

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template