本文整理匯總了PHP中Patchwork\Utf8::str_pad方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utf8::str_pad方法的具體用法?PHP Utf8::str_pad怎麽用?PHP Utf8::str_pad使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Patchwork\Utf8
的用法示例。
在下文中一共展示了Utf8::str_pad方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_str_pad
public function test_str_pad()
{
$toPad = '<IñtërnëT>';
// 10 characters
$padding = 'ø__';
// 4 characters
$this->assertEquals($toPad . ' ', u::str_pad($toPad, 20));
$this->assertEquals(' ' . $toPad, u::str_pad($toPad, 20, ' ', STR_PAD_LEFT));
$this->assertEquals(' ' . $toPad . ' ', u::str_pad($toPad, 20, ' ', STR_PAD_BOTH));
$this->assertEquals($toPad, u::str_pad($toPad, 10));
$this->assertEquals('5char', str_pad('5char', 4));
// str_pos won't truncate input string
$this->assertEquals($toPad, u::str_pad($toPad, 8));
$this->assertEquals($toPad . 'ø__ø__ø__ø', u::str_pad($toPad, 20, $padding, STR_PAD_RIGHT));
$this->assertEquals('ø__ø__ø__ø' . $toPad, u::str_pad($toPad, 20, $padding, STR_PAD_LEFT));
$this->assertEquals('ø__ø_' . $toPad . 'ø__ø_', u::str_pad($toPad, 20, $padding, STR_PAD_BOTH));
}
示例2:
/**
* @covers Patchwork\Utf8::str_pad
*/
function testStr_pad()
{
$this->assertSame('ÉÈà-à-à-à-', u::str_pad('ÉÈ', 10, 'à-', STR_PAD_RIGHT));
$this->assertSame('à-à-à-à-ÉÈ', u::str_pad('ÉÈ', 10, 'à-', STR_PAD_LEFT));
$this->assertSame('à-à-ÉÈà-à-', u::str_pad('ÉÈ', 10, 'à-', STR_PAD_BOTH));
}