• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP in_string函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中in_string函数的典型用法代码示例。如果您正苦于以下问题:PHP in_string函数的具体用法?PHP in_string怎么用?PHP in_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了in_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: load

 /**
  * Converts an XML url or string to a PHP array format
  *
  * @static
  * @access public
  * @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which.
  * @return array Parsed XML
  * @throws BadEntryError
  * @throws DependencyError
  * @throws HookError
  * @throws XMLError
  */
 public static function load($data)
 {
     $http = HTTP::getDefaultInstance();
     if (!function_exists('simplexml_load_string')) {
         throw new DependencyError("SimpleXML", "http://us.php.net/manual/en/book.simplexml.php");
     }
     libxml_use_internal_errors(true);
     if (in_string("<?xml", $data)) {
         $xmlout = $data;
     } else {
         $xmlout = $http->get($data);
     }
     Hooks::runHook('PreSimpleXMLLoad', array(&$xmlout));
     $xml = simplexml_load_string($xmlout);
     Hooks::runHook('PostSimpleXMLLoad', array(&$xml));
     if (!$xml) {
         foreach (libxml_get_errors() as $error) {
             throw new XMLError($error);
         }
     }
     $outArr = array();
     $namespaces = $xml->getNamespaces(true);
     $namespaces['default'] = '';
     self::recurse($xml, $outArr, $namespaces);
     libxml_clear_errors();
     return $outArr;
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:39,代码来源:XMLParse.php


示例2: getBlameResult

 public static function getBlameResult($wiki, $article, $nofollowredir, $text)
 {
     try {
         $site = Peachy::newWiki(null, null, null, 'http://' . $wiki . '/w/api.php');
     } catch (Exception $e) {
         return null;
     }
     $pageClass = $site->initPage($article, null, !$nofollowredir);
     $title = $pageClass->get_title();
     $history = $pageClass->history(null, 'older', true);
     $revs = array();
     foreach ($history as $id => $rev) {
         if ($id + 1 == count($history)) {
             if (in_string($text, $rev['*'], true)) {
                 $revs[] = self::parseRev($rev, $wiki, $title);
             }
         } else {
             if (in_string($text, $rev['*'], true) && !in_string($text, $history[$id + 1]['*'], true)) {
                 $revs[] = self::parseRev(${$rev}, $wiki, $title);
             }
         }
         unset($rev);
         //Saves memory
     }
     return $revs;
 }
开发者ID:JackPotte,项目名称:xtools,代码行数:26,代码来源:base.php


示例3: p11n

function p11n($locale)
{
    $args = func_get_args();
    $locale = array_shift($args);
    $num_args = count($args);
    if ($num_args == 0) {
        return $locale;
    }
    if (in_string('|', $locale)) {
        $n = NULL;
        $locale = explode('|', $locale);
        $count = count($locale);
        foreach ($locale as $i => &$l) {
            if (preg_match('/^\\{(\\d+?)\\}|\\[(\\d+?),(\\d+?|Inf)\\]/', $l, $match)) {
                $n = end($match);
                if ($n == 'Inf') {
                    break;
                }
            } else {
                if (is_null($n)) {
                    $l = '[0,1]' . $l;
                    $n = 1;
                } else {
                    if ($i == $count - 1) {
                        $l = '[' . ++$n . ',Inf]' . $l;
                    } else {
                        $l = '{' . ++$n . '}' . $l;
                    }
                }
            }
        }
        unset($l);
        foreach ($locale as $l) {
            if (preg_match('/^\\{(\\d+?)\\}(.*)/', $l, $match) && $args[0] == $match[1]) {
                $locale = $match[2];
                unset($args[0]);
                break;
            } else {
                if (preg_match('/^\\[(\\d+?),(\\d+?|Inf)\\](.*)/', $l, $match) && $args[0] >= $match[1] && ($match[2] == 'Inf' || $args[0] <= $match[2])) {
                    $locale = $match[3];
                    unset($args[0]);
                    break;
                }
            }
        }
        if (is_array($locale)) {
            return FALSE;
        }
    }
    array_unshift($args, $locale);
    return call_user_func_array('sprintf', $args);
}
开发者ID:agreements,项目名称:neofrag-cms,代码行数:52,代码来源:i18n.php


示例4: callFunction

	public static function callFunction( $name, $args, $context, $line ) {
		if( !in_string( '_', $name ) ) {
			$context->error( 'unknownfunction', $line, array( $name ) );
		}

		list( $prefix, $realName ) = explode( '_', $name, 2 );
		$module = self::getModule( $prefix );
		if( !$module || !in_array( $realName, $module->getFunctionList() ) ) {
			$context->error( 'unknownfunction', $line, array( $name ) );
		}

		return $module->callFunction( $realName, $args, $context, $line );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:Library.php


示例5: runHook

 /**
  * Search for hook functions and run them if defined
  *
  * @param string $hook_name Name of hook to search for
  * @param array $args Arguments to pass to the hook function
  * @throws HookError
  * @throws BadEntryError
  * @return mixed Output of hook function
  */
 public static function runHook($hook_name, $args = array())
 {
     global $pgHooks;
     if (!isset($pgHooks[$hook_name])) {
         return null;
     }
     if (!is_array($pgHooks[$hook_name])) {
         throw new HookError("Hook assignment for event `{$hook_name}` is not an array. Syntax is " . '$pgHooks[\'hookname\'][] = "hook_function";');
     }
     $method = null;
     foreach ($pgHooks[$hook_name] as $function) {
         if (is_array($function)) {
             if (count($function) < 2) {
                 throw new HookError("Not enough parameters in array specified for `{$hook_name}` hook");
             } elseif (is_object($function[0])) {
                 $object = $function[0];
                 $method = $function[1];
                 if (count($function) > 2) {
                     $data = $function[2];
                 }
             } elseif (is_string($function[0])) {
                 $method = $function[0];
                 if (count($function) > 1) {
                     $data = $function[1];
                 }
             }
         } elseif (is_string($function)) {
             $method = $function;
         }
         if (isset($data)) {
             $args = array_merge(array($data), $args);
         }
         if (isset($object)) {
             $fncarr = array($object, $method);
         } elseif (is_string($method) && in_string("::", $method)) {
             $fncarr = explode("::", $method);
         } else {
             $fncarr = $method;
         }
         //is_callable( $fncarr ); //Apparently this is a bug. Thanks, MW!
         if (!is_callable($fncarr)) {
             throw new BadEntryError("MissingFunction", "Hook function {$fncarr} was not defined");
         }
         $hookRet = call_user_func_array($fncarr, $args);
         if (!is_null($hookRet)) {
             return $hookRet;
         }
     }
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:58,代码来源:Hooks.php


示例6: apply_labels

function apply_labels($dbh, $id, $user)
{
    $labels = null;
    $label_data = $dbh->prepare("SELECT * FROM cm_messages WHERE id = '{$id}'");
    $label_data->execute();
    $ld = $label_data->fetch(PDO::FETCH_ASSOC);
    if (in_string($user, $ld['archive'])) {
        $labels .= '<span class="label_archive">Archive</span>';
    } else {
        $labels .= '<span class="label_inbox">Inbox</span>';
    }
    if ($ld['from'] == $user) {
        $labels .= '<span class="label_sent">Sent</span>';
    }
    return $labels;
}
开发者ID:samtechnocrat,项目名称:ClinicCases,代码行数:16,代码来源:messages_load.php


示例7: jsonSerialize

 public function jsonSerialize()
 {
     $fields = [];
     $reflection = new \ReflectionClass($this);
     foreach ($reflection->getMethods() as $method) {
         if (substr($method->getName(), 0, 3) !== 'get') {
             continue;
         }
         if (in_string("@JsonIgnore", $method->getDocComment())) {
             continue;
         }
         $underscore = preg_replace('/([a-z])([A-Z])/', '$1_$2', substr($method->getName(), 3));
         $fields[strtolower($underscore)] = $method->invoke($this);
     }
     return $fields;
 }
开发者ID:pldin601,项目名称:HomeMusic,代码行数:16,代码来源:AbstractPersistentObject.php


示例8: getQuotesFromSearch

 public function getQuotesFromSearch($search, $regex = false)
 {
     $retArr = array();
     foreach ($this->quotes as $id => $quote) {
         if ($regex) {
             if (preg_match($search, html_entity_decode($quote))) {
                 $retArr[$id + 1] = $quote;
             }
         } else {
             if (in_string($search, $quote, false) === true) {
                 $retArr[$id + 1] = $quote;
             }
         }
     }
     return $retArr;
 }
开发者ID:Krinkle,项目名称:xtools,代码行数:16,代码来源:base.php


示例9: __construct

 public function __construct()
 {
     parent::__construct();
     $this->_configs['base_url'] = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
     $this->_configs['request_url'] = $_SERVER['REQUEST_URI'] != $this->_configs['base_url'] ? substr($_SERVER['REQUEST_URI'], strlen($this->_configs['base_url'])) : 'index.html';
     $this->_configs['extension_url'] = extension($this->_configs['request_url'], $this->_configs['request_url']);
     $this->_configs['ajax_header'] = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
     $ext = extension($url = !empty($_GET['request_url']) ? $_GET['request_url'] : $this->_configs['request_url'], $url);
     $this->_configs['segments_url'] = explode('/', rtrim(substr($url, 0, -strlen($ext)), '.'));
     if ($this->_configs['segments_url'][0] == 'admin') {
         $this->_configs['admin_url'] = TRUE;
     }
     if (empty($this->_configs['admin_url']) && $this->_configs['segments_url'][0] == 'ajax' || !empty($this->_configs['admin_url']) && isset($this->_configs['segments_url'][1]) && $this->_configs['segments_url'][1] == 'ajax') {
         $this->_configs['ajax_url'] = TRUE;
     }
     if (is_null($configs = NeoFrag::loader()->db->select('site, lang, name, value, type')->from('nf_settings')->get())) {
         exit('Database is empty');
     }
     foreach ($configs as $setting) {
         if ($setting['type'] == 'array') {
             $value = unserialize(utf8_html_entity_decode($setting['value']));
         } else {
             if ($setting['type'] == 'list') {
                 $value = explode('|', $setting['value']);
             } else {
                 if ($setting['type'] == 'bool') {
                     $value = (bool) $setting['value'];
                 } else {
                     if ($setting['type'] == 'int') {
                         $value = (int) $setting['value'];
                     } else {
                         $value = $setting['value'];
                     }
                 }
             }
         }
         $this->_settings[$setting['site']][$setting['lang']][$setting['name']] = $value;
         if (empty($site) && $setting['name'] == 'nf_domains' && in_string($_SERVER['HTTP_HOST'], $setting['value'])) {
             $site = $value;
         }
     }
     $this->update('');
     $this->update('default');
     if (!empty($site)) {
         $this->update('default');
     }
 }
开发者ID:nsystem1,项目名称:neofrag-cms,代码行数:47,代码来源:config.php


示例10: parse

 public function parse($content, $data = array(), $loader = NULL, $parse_php = TRUE)
 {
     if (!$loader) {
         $loader = $this->load;
     }
     if ($parse_php && is_callable($content)) {
         $content = call_user_func($content, $data, $loader);
     } else {
         if (in_string('<?php', $content) && in_string('?>', $content)) {
             $NeoFrag = $this->load;
             $paths = $loader->paths;
             $GLOBALS['loader'] = $loader;
             //Récupèration du contenu du template avec exécution du code PHP
             $content = eval('ob_start(); ?>' . preg_replace('/;*\\s*\\?>/', '; ?>', str_replace('<?=', '<?php echo ', $content)) . '<?php return ob_get_clean();');
         }
     }
     return $content;
 }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:18,代码来源:template.php


示例11: display

    public static function display($disposition_id, $disposition, $page, $zone_id)
    {
        global $NeoFrag;
        $output = display($disposition, NeoFrag::live_editor() ? $zone_id : NULL);
        if (!NeoFrag::live_editor() && in_string('<div class="module', $output)) {
            $output .= $NeoFrag->profiler->output();
        }
        if (NeoFrag::live_editor()) {
            if (NeoFrag::live_editor() & NeoFrag::ZONES) {
                $output = '	<div class="pull-right">
								' . ($page == '*' ? '<button type="button" class="btn btn-link live-editor-fork" data-enable="0">' . icon('fa-toggle-off') . ' ' . $NeoFrag->lang('common_layout') . '</button>' : '<button type="button" class="btn btn-link live-editor-fork" data-enable="1">' . icon('fa-toggle-on') . ' ' . $NeoFrag->lang('custom_layout') . '</button>') . '
							</div>
							<h3>' . (!empty($NeoFrag->load->theme->zones[$zone_id]) ? $NeoFrag->load->theme->load->lang($NeoFrag->load->theme->zones[$zone_id], NULL) : $NeoFrag->lang('zone', $zone_id)) . ' <div class="btn-group"><button type="button" class="btn btn-xs btn-success live-editor-add-row" data-toggle="tooltip" data-container="body" title="' . $NeoFrag->lang('new_row') . '">' . icon('fa-plus') . '</button></div></h3>' . $output;
            }
            $output = '<div' . (NeoFrag::live_editor() & NeoFrag::ZONES ? ' class="live-editor-zone"' : '') . ' data-disposition-id="' . $disposition_id . '">' . $output . '</div>';
        }
        return $output;
    }
开发者ID:agreements,项目名称:neofrag-cms,代码行数:18,代码来源:zone.php


示例12: delete

 public static function delete($track_id)
 {
     if (empty($track_id)) {
         throw new ControllerException("At lease one track id must be specified");
     }
     $track_ids = in_string(",", $track_id) ? explode(",", $track_id) : array($track_id);
     self::validateListOfTrackIds($track_ids);
     $track_objects = self::getTracksListById($track_ids);
     $isTrackBelongsToUser = function ($track) {
         return $track[TSongs::USER_ID] == self::$me->getId();
     };
     if (!$track_objects->all($isTrackBelongsToUser)) {
         throw new ControllerException("One or more selected tracks is not belongs to you");
     }
     foreach ($track_objects as $track) {
         Logger::printf("Removing track %s", $track[TSongs::ID]);
         self::removeFilesUsedByTrack($track);
     }
     self::deleteTracksById($track_ids);
 }
开发者ID:pldin601,项目名称:HomeMusic,代码行数:20,代码来源:Songs.php


示例13: getBlameResult

function getBlameResult(&$pageClass, $text)
{
    $history = $pageClass->history(null, 'older', true);
    $list = '';
    $anz = count($history);
    foreach ($history as $id => $rev) {
        if (in_string($text, $rev['*'], true) && ($id + 1 == $anz || !in_string($text, $history[$id + 1]['*'], true))) {
            $date = date('Y-m-d, H:i ', strtotime($rev['timestamp']));
            $year = date('Y', strtotime($rev['timestamp']));
            $month = date('m', strtotime($rev['timestamp']));
            $minor = $row['rev_minor_edit'] == '1' ? '<span class="minor" >m</span>' : '';
            $list .= '
				<tr>
				<td style="font-size:95%; white-space:nowrap;">' . $date . ' &middot; </td>
				<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&amp;diff=prev&amp;oldid=' . $rev['revid'] . '" title="' . $title . '">diff</a>)</td>
				<td>(<a href="//{$domain}/w/index.php?title={$urlencodedpage}&amp;action=history&amp;year=' . $year . '&amp;month=' . $month . ' " title="' . $title . '">hist</a>)</td>
				<td><a href="//{$domain}/wiki/User:' . $rev['user'] . '" title="User:' . $rev['user'] . '">' . $rev['user'] . '</a> </td>
				<td style="font-size:85%" > &middot; ' . htmlspecialchars($rev['comment']) . '</td>
				</tr>
			';
        }
    }
    return $list;
}
开发者ID:Krinkle,项目名称:xtools,代码行数:24,代码来源:index.php


示例14: isCountable

 /**
  * Determine whether a page would be suitable for being counted as an
  * article in the site_stats table based on the title & its content
  *
  * @param $text String: text to analyze
  * @return bool
  */
 public function isCountable($text)
 {
     global $wgUseCommaCount;
     $token = $wgUseCommaCount ? ',' : '[[';
     return $this->mTitle->isContentPage() && !$this->isRedirect($text) && in_string($token, $text);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:13,代码来源:Article.php


示例15: test_in_string

 /**
  * @dataProvider provide_in_string
  * @covers ::in_string
  * @param $needle
  * @param $haystack
  * @param $insensitive
  * @param $expected
  */
 public function test_in_string($needle, $haystack, $insensitive, $expected)
 {
     $this->assertEquals($expected, in_string($needle, $haystack, $insensitive));
 }
开发者ID:emijrp,项目名称:Peachy,代码行数:12,代码来源:GenFunctionsTest.php


示例16: isCountable

 /**
  * Determine whether a page  would be suitable for being counted as an
  * article in the site_stats table based on the title & its content
  *
  * @param $text String: text to analyze
  * @return bool
  */
 function isCountable($text)
 {
     global $wgUseCommaCount, $wgContentNamespaces;
     $token = $wgUseCommaCount ? ',' : '[[';
     return array_search($this->mTitle->getNamespace(), $wgContentNamespaces) !== false && !$this->isRedirect($text) && in_string($token, $text);
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:13,代码来源:Article.php


示例17: testInString

 /**
  * @dataProvider inStringProvider
  * @param $haystack
  * @param $needle
  * @param $result
  */
 public function testInString($haystack, $needle, $caseInsensitive, $result)
 {
     $this->assertEquals($result, in_string($haystack, $needle, $caseInsensitive));
 }
开发者ID:woodworker,项目名称:ww-helper,代码行数:10,代码来源:StringTest.php


示例18: braceSubstitution


//.........这里部分代码省略.........
             # modifiers such as RAW: produce separate cache entries
             if ($found) {
                 if ($isHTML) {
                     // A special page; don't store it in the template cache.
                 } else {
                     $this->mTemplates[$piece['title']] = $text;
                 }
                 $text = $linestart . $text;
             }
         }
         wfProfileOut(__METHOD__ . '-loadtpl');
     }
     if ($found && !$this->incrementIncludeSize('pre-expand', strlen($text))) {
         # Error, oversize inclusion
         $text = $linestart . "[[{$titleText}]]<!-- WARNING: template omitted, pre-expand include size too large -->";
         $noparse = true;
         $noargs = true;
     }
     # Recursive parsing, escaping and link table handling
     # Only for HTML output
     if ($nowiki && $found && ($this->ot['html'] || $this->ot['pre'])) {
         $text = wfEscapeWikiText($text);
     } elseif (!$this->ot['msg'] && $found) {
         if ($noargs) {
             $assocArgs = array();
         } else {
             # Clean up argument array
             $assocArgs = self::createAssocArgs($args);
             # Add a new element to the templace recursion path
             $this->mTemplatePath[$part1] = 1;
         }
         if (!$noparse) {
             # If there are any <onlyinclude> tags, only include them
             if (in_string('<onlyinclude>', $text) && in_string('</onlyinclude>', $text)) {
                 $replacer = new OnlyIncludeReplacer();
                 StringUtils::delimiterReplaceCallback('<onlyinclude>', '</onlyinclude>', array(&$replacer, 'replace'), $text);
                 $text = $replacer->output;
             }
             # Remove <noinclude> sections and <includeonly> tags
             $text = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $text);
             $text = strtr($text, array('<includeonly>' => '', '</includeonly>' => ''));
             if ($this->ot['html'] || $this->ot['pre']) {
                 # Strip <nowiki>, <pre>, etc.
                 $text = $this->strip($text, $this->mStripState);
                 if ($this->ot['html']) {
                     $text = Sanitizer::removeHTMLtags($text, array(&$this, 'replaceVariables'), $assocArgs);
                 } elseif ($this->ot['pre'] && $this->mOptions->getRemoveComments()) {
                     $text = Sanitizer::removeHTMLcomments($text);
                 }
             }
             $text = $this->replaceVariables($text, $assocArgs);
             # If the template begins with a table or block-level
             # element, it should be treated as beginning a new line.
             if (!$piece['lineStart'] && preg_match('/^(?:{\\||:|;|#|\\*)/', $text)) {
                 $text = "\n" . $text;
             }
         } elseif (!$noargs) {
             # $noparse and !$noargs
             # Just replace the arguments, not any double-brace items
             # This is used for rendered interwiki transclusion
             $text = $this->replaceVariables($text, $assocArgs, true);
         }
     }
     # Prune lower levels off the recursion check path
     $this->mTemplatePath = $lastPathLevel;
     if ($found && !$this->incrementIncludeSize('post-expand', strlen($text))) {
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:67,代码来源:Parser_OldPP.php


示例19: in_string

function in_string($needle, $haystack)
{
    if (is_array($needle)) {
        $result = true;
        foreach ($needle as $sub_needle) {
            $result = in_string($sub_needle, $haystack) && $result;
        }
    } else {
        $result = stripos($haystack, $needle) !== false;
    }
    return $result;
}
开发者ID:m1ke,项目名称:easy-site-utils,代码行数:12,代码来源:string.php


示例20: while

$q = $dbh->prepare($sql);
$q->execute();
$error = $q->errorInfo();
while ($result = $q->fetch(PDO::FETCH_ASSOC)) {
    $rows = array();
    //Add user picture
    $pic = "<img class='thumbnail-mask' src='" . return_thumbnail($dbh, $result['username']) . "' border='0'>";
    $rows[] = $pic;
    //Format data
    $result['username'] = username_to_fullname($dbh, $result['username']);
    $result['date_added'] = extract_date_time_sortable($result['date_added']);
    //Check to see if this user has read or archived this journal
    if (in_string($user, $result['read'])) {
        $result['read'] = 'yes';
    } else {
        $result['read'] = '';
    }
    if (in_string($user, $result['archived'])) {
        $result['archived'] = 'yes';
    } else {
        $result['archived'] = '';
    }
    foreach ($cols as $col) {
        $rows[] = $result[$col];
    }
    $output['aaData'][] = $rows;
}
if ($q->rowCount() < 1) {
    $output['aaData'] = array();
}
echo json_encode($output);
开发者ID:samtechnocrat,项目名称:ClinicCases,代码行数:31,代码来源:journals_load.php



注:本文中的in_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP in_the_loop函数代码示例发布时间:2022-05-15
下一篇:
PHP in_coventry函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap