| str_pad() | ใช้แทรกข้อความ ( value ) เข้าไปใน string เพื่อให้มีขนาดเท่ากับที่กำหนด ( length ) |
|---|
function:str_pad ( string, length, value, type );
return type:string
content:ใช้แทรกข้อความ ( value ) เข้าไปใน string เพื่อให้มีขนาดเท่ากับที่กำหนด ( length )
example:$string = "700"; echo str_pad ( $string, 5, " ", STR_PAD_LEFT ); echo str_pad ( $string, strlen ( $string ) + 3, ".00", STR_PAD_RIGHT );
comment:ถ้า type = STR_PAD_RIGHT คือ เพิ่มทางขวา ( default ) ถ้า type = STR_PAD_LEFT คือ เพิ่มทางซ้าย ถ้า type = STR_PAD_BOTH คือ เพิ่มทั้งทางซ้ายและทางขวา