本文整理汇总了PHP中textlib::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP textlib::strpos方法的具体用法?PHP textlib::strpos怎么用?PHP textlib::strpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类textlib
的用法示例。
在下文中一共展示了textlib::strpos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: game_cryptex_continue
function game_cryptex_continue($id, $game, $attempt, $cryptexrec, $endofgame, $context)
{
global $DB, $USER;
if ($endofgame) {
game_updateattempts($game, $attempt, -1, true);
$endofgame = false;
}
if ($attempt != false and $cryptexrec != false) {
$crossm = $DB->get_record('game_cross', array('id' => $attempt->id));
return game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context);
}
if ($attempt === false) {
$attempt = game_addattempt($game);
}
$cryptex = new CryptexDB();
$questions = array();
$infos = array();
$answers = array();
$recs = game_questions_shortanswer($game);
if ($recs == false) {
print_error(get_string('no_words', 'game'));
}
$infos = array();
$reps = array();
foreach ($recs as $rec) {
if ($game->param7 == false) {
if (textlib::strpos($rec->answertext, ' ')) {
continue;
//spaces not allowed
}
}
$rec->answertext = game_upper($rec->answertext);
$answers[$rec->answertext] = game_repairquestion($rec->questiontext);
$infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid);
$a = array('gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false) {
$reps[$rec->answertext] = $rec2->r;
}
}
$cryptex->setwords($answers, $game->param1, $reps);
if ($cryptex->computedata($crossm, $crossd, $letters, $game->param2)) {
$new_crossd = array();
foreach ($crossd as $rec) {
if (array_key_exists($rec->answertext, $infos)) {
$info = $infos[$rec->answertext];
$rec->id = 0;
$rec->sourcemodule = $info[0];
$rec->questionid = $info[1];
$rec->glossaryentryid = $info[2];
}
game_update_queries($game, $attempt, $rec, 0, '');
$new_crossd[] = $rec;
}
$cryptexrec = $cryptex->savecryptex($game, $crossm, $new_crossd, $attempt->id, $letters);
}
game_updateattempts($game, $attempt, 0, 0);
return game_cryptex_play($id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context);
}
示例2: game_cross_new
function game_cross_new($game, $attemptid, &$crossm)
{
global $DB, $USER;
$cross = new CrossDB();
$questions = array();
$infos = array();
$answers = array();
$recs = game_questions_shortanswer($game);
if ($recs == false) {
print_error('game_cross_continue: ' . get_string('no_words', 'game'));
}
$infos = array();
$reps = array();
foreach ($recs as $rec) {
if ($game->param7 == false) {
if (textlib::strpos($rec->answertext, ' ')) {
continue;
//spaces not allowed
}
}
$rec->answertext = game_upper($rec->answertext);
$answers[$rec->answertext] = game_repairquestion($rec->questiontext);
$infos[$rec->answertext] = array($game->sourcemodule, $rec->questionid, $rec->glossaryentryid, $rec->attachment);
$a = array('gameid' => $game->id, 'userid' => $USER->id, 'questionid' => $rec->questionid, 'glossaryentryid' => $rec->glossaryentryid);
if (($rec2 = $DB->get_record('game_repetitions', $a, 'id,repetitions r')) != false) {
$reps[$rec->answertext] = $rec2->r;
}
}
$cross->setwords($answers, $game->param1, $reps);
//game->param2 is maximum words in crossword
if ($cross->computedata($crossm, $crossd, $lettets, $game->param2)) {
$new_crossd = array();
foreach ($crossd as $rec) {
$info = $infos[$rec->answertext];
if ($info != false) {
$rec->sourcemodule = $info[0];
$rec->questionid = $info[1];
$rec->glossaryentryid = $info[2];
$rec->attachment = $info[3];
}
$new_crossd[] = $rec;
}
$cross->savecross($game, $crossm, $new_crossd, $attemptid);
}
if (count($crossd) == 0) {
print_error('game_cross_continue: ' . get_string('no_words', 'game'));
}
}
示例3: test_strpos
/**
* Tests the static strpos method
* @return void
*/
public function test_strpos()
{
$str = "Žluťoučký koníček";
$this->assertSame(textlib::strpos($str, 'koníč'), 10);
}
示例4: game_strpos
function game_strpos($haystack, $needle, $offset = 0)
{
if (game_get_moodle_version() >= '02.08') {
return core_text::strpos($haystack, $needle, $offset);
}
if (game_get_moodle_version() >= '02.04') {
return textlib::strpos($haystack, $needle, $offset);
}
return textlib_get_instance()->strpos($haystack, $needle, $offset);
}
示例5: hangman_existall
function hangman_existall($str, $strfind)
{
$n = textlib::strlen($str);
for ($i = 0; $i < $n; $i++) {
$pos = textlib::strpos($strfind, textlib::substr($str, $i, 1));
if ($pos === false) {
return false;
}
}
return true;
}
示例6: hangman_onincorrect
function hangman_onincorrect($id, $word_line, $word, $game, $attempt, $hangman, $onlyshow, $showsolution)
{
echo "\r\n<BR/><BR/><font size=\"5\">\n{$word_line}</font>\r\n";
if ($onlyshow or $showsolution) {
return;
}
echo '<p><BR/><font size="5" color="red">' . get_string('hangman_loose', 'game') . '</font><BR/><BR/></p>';
if ($game->param6) {
//show the correct answer
if (textlib::strpos($word, ' ') != false) {
echo '<br/>' . get_string('hangman_correct_phrase', 'game');
} else {
echo '<br/>' . get_string('hangman_correct_word', 'game');
}
echo '<B>' . $word . "</B><BR/><BR/>\r\n";
}
game_hangman_show_nextword($id, $game, $attempt, $hangman, true);
}