本文整理汇总了PHP中StringUtil::reverse方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::reverse方法的具体用法?PHP StringUtil::reverse怎么用?PHP StringUtil::reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::reverse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create($form = null, $modelType = null, $modelNumber = null, $restriction = '')
{
$l = Model::factory('Lexem')->create();
if ($form) {
$l->form = $form;
$l->formNoAccent = str_replace("'", '', $form);
$l->formUtf8General = $l->formNoAccent;
$l->reverse = StringUtil::reverse($l->formNoAccent);
}
$l->description = '';
$l->tags = '';
$l->source = '';
$l->modelType = $modelType;
$l->modelNumber = $modelNumber;
$l->restriction = $restriction;
$l->comment = '';
$l->isLoc = false;
$l->noAccent = false;
return $l;
}
示例2: assert
assert(count($parts) == 2);
$lm = $lexem->getFirstLexemModel();
$lm->modelType = $parts[0];
$lm->modelNumber = $parts[1];
$lm->restriction = util_getRequestParameter('restr_' . $lexem->id);
$lm->save();
$lm->regenerateParadigm();
} else {
$lexem->comment = util_getRequestParameter('comment_' . $lexem->id);
$lexem->save();
}
}
}
util_redirect("bulkLabel.php?suffix={$suffix}");
}
$reverseSuffix = StringUtil::reverse($suffix);
RecentLink::createOrUpdate("Etichetare asistată: -{$suffix}");
$numLabeled = Model::factory('Lexem')->table_alias('l')->join('LexemModel', 'lm.lexemId = l.id', 'lm')->where_not_equal('lm.modelType', 'T')->where_like('l.reverse', "{$reverseSuffix}%")->count();
// Collect all the models that appear in at least 5% of the already
// labeled lexems. Always select at least one model, in the unlikely case
// that no model has over 5%.
$models = array();
$hasInvariableModel = false;
$dbResult = db_execute("select canonical, modelNumber, count(*) as c " . "from Lexem " . "join LexemModel on lexemId = Lexem.id " . "join ModelType on modelType = code " . "where modelType != 'T' " . "and reverse like '{$reverseSuffix}%' " . "group by canonical, modelNumber " . "order by c desc", PDO::FETCH_ASSOC);
foreach ($dbResult as $row) {
$modelType = $row['canonical'];
$modelNumber = $row['modelNumber'];
$count = $row['c'];
if (!count($models) || $count / $numLabeled >= 0.05) {
if ($modelType == 'V' || $modelType == 'VT') {
$m = Model::factory('FlexModel')->where('modelType', 'V')->where('number', $modelNumber)->find_one();
示例3: testReverse_Multibyte
/**
* @test
*/
public function testReverse_Multibyte()
{
// 現在の実装のままだとテストが通らない
$text = 'テスト';
$this->assertThat(StringUtil::reverse($text), $this->equalTo('トステ'));
}
示例4: preg_split
$parts = preg_split('/_/', $name);
assert(count($parts) == 2);
$lexemId = $parts[1];
if (!array_key_exists($lexemId, $lexemMap)) {
$lexemMap[$lexemId] = Lexem::get_by_id($lexemId);
}
$l = $lexemMap[$lexemId];
switch ($parts[0]) {
case 'caps':
if (StringUtil::startsWith($l->form, "'")) {
$l->form = "'" . AdminStringUtil::capitalize(mb_substr($l->form, 1));
} else {
$l->form = AdminStringUtil::capitalize($l->form);
}
$l->formNoAccent = str_replace("'", '', $l->form);
$l->reverse = StringUtil::reverse($l->formNoAccent);
break;
case 'singular':
$l->restriction = 'S';
break;
case 'plural':
$l->restriction = 'P';
break;
case 'model':
if ($value) {
$m = Model::factory('FlexModel')->where_raw("concat(modelType, number) = '{$value}'")->find_one();
if ($m) {
$oldModelType = $l->modelType;
$oldModelNumber = $l->modelNumber;
$l->modelType = $m->modelType;
$l->modelNumber = $m->number;
示例5: save
public function save()
{
$this->formUtf8General = $this->formNoAccent;
$this->reverse = StringUtil::reverse($this->formNoAccent);
$this->charLength = mb_strlen($this->formNoAccent);
$this->consistentAccent = strpos($this->form, "'") !== false ^ $this->noAccent;
// It is important for empty fields to be null, not "".
// This allows the admin report for lexems *with* comments to run faster.
if ($this->comment == '') {
$this->comment = null;
}
if (!$this->number) {
$this->number = null;
}
parent::save();
}
示例6: assertEquals
assertEquals('abcúùû', mb_strtolower('ABCÚÙÛ'));
assertEquals('ÿ', mb_strtolower('Ÿ'));
assertEquals('MAMA', mb_strtoupper('MAMA'));
assertEquals('MAMA', mb_strtoupper('MAmA'));
assertEquals('MAMA', mb_strtoupper('MAmA'));
assertEquals('MAMĂ', mb_strtoupper('MamĂ'));
assertEquals('MAMĂ', mb_strtoupper('maMă'));
assertEquals('ABCÚÙÛ', mb_strtoupper('abcúùû'));
assertEquals('Ÿ', mb_strtoupper('ÿ'));
// Check that we're using the right encoding
assertEquals(mb_strlen('íÍìÌîÎ'), 6);
assertEquals(mb_substr('íÍìÌîÎ', 3, 2), 'Ìî');
// Test string reversal
assertEquals('cba', StringUtil::reverse('abc'));
assertEquals('țșîâă', StringUtil::reverse('ăâîșț'));
assertEquals('ȚȘÎÂĂ', StringUtil::reverse('ĂÂÎȘȚ'));
// Check suffix removals
assertEquals(AdminStringUtil::removeKnownSuffixes(''), '');
assertEquals(AdminStringUtil::removeKnownSuffixes('mama'), 'mama');
assertEquals(AdminStringUtil::removeKnownSuffixes('farmaciei'), 'farmacie');
assertEquals(AdminStringUtil::removeKnownSuffixes('dealului'), 'deal');
assertEquals(AdminStringUtil::removeKnownSuffixes('dealul'), 'deal');
assertEquals(AdminStringUtil::removeKnownSuffixes('dealuri'), 'deal');
assertEquals(AdminStringUtil::removeKnownSuffixes('dealurilor'), 'deal');
assertEquals(AdminStringUtil::removeKnownSuffixes('copacilor'), 'copac');
assertEquals(AdminStringUtil::removeKnownSuffixes('bogată'), 'bogat');
assertEquals(AdminStringUtil::removeKnownSuffixes('bogate'), 'bogat');
assertEquals(AdminStringUtil::getLastWord(''), '');
assertEquals(AdminStringUtil::getLastWord('foo'), 'foo');
assertEquals(AdminStringUtil::getLastWord('foo bar'), 'bar');
assertEquals(AdminStringUtil::getLastWord('foo bar (@1@)'), 'bar');