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

PHP preg_filter函数代码示例

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

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



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

示例1: parse

 /**
  *
  * Parse the file in 1 go
  *
  */
 function parse()
 {
     $pattern = array('/^Name\\s*:\\s*(.*)$/i', '/^Version\\s*:\\s*(.*)$/i', '/^Release\\s*:\\s*(\\S*)(%\\{\\?dist\\}).*$/', '/^Release\\s*:\\s*(\\S*)$/', '/^Summary\\s*:\\s*(.*)$/i', '/^License\\s*:\\s*(.*)$/i', '/^URL\\s*:\\s*(.*)$/i', '/^Epoch\\s*:\\s*(.*)/i', '/^Group\\s*:\\s*(.*)$/i', '/^%define\\s*(\\S*)\\s*(\\S*)\\s*$/i', '/^%description\\s*$/i', '/^%description\\s*(.*)$/i', '/^%description\\s*:(.*)$/', '/%package\\s*(.*)$/i', '/^Requires\\s*:(.*)$/i', '/^Obsoletes\\s*:(.*)$/i', '/^Conflicts\\s*:(.*)$/i', '/^Provides\\s*:(.*)$/i', '/^BuildRequires\\s*:(.*)$/i', '/^%(\\S+)\\s*(.*)$/i', '/^.*$/');
     $replace = array('name: $1', 'version: $1', 'release: $1' . $this->distribution, 'release: $1', 'summary: $1', 'license: $1', 'url: $1', 'epoch: $1', 'group: $1', '$1: $2', 'description: $1', 'description: $1', 'description: $1', 'package: $1', 'depends: $1', 'obsoletes: $1', 'conflicts: $1', 'provides: $1', 'buildDepends: $1', '$1: $2', '$0');
     // parse the file in 1 go
     while (($buffer = fgets($this->handle, $this->blocksize)) !== false) {
         $result = preg_filter($pattern, $replace, $buffer);
         if ($result) {
             $info = explode(':', $result, 2);
         }
     }
     if ($this->_flag_debug) {
         echo "\nDependencies\n";
         echo "---------------------\n";
         print_r($this->depends);
         echo "\nBuild Dependencies\n";
         echo "---------------------\n";
         print_r($this->buildDepends);
         echo "\nProvides\n";
         echo "---------------------\n";
         print_r($this->provides);
         echo "\nObsoletes\n";
         echo "---------------------\n";
         print_r($this->obsoletes);
         echo "\nConflicts\n";
         echo "---------------------\n";
         print_r($this->conflicts);
         echo "\nSubpackages\n";
         echo "---------------------\n";
         print_r($this->subpackages);
     }
     unset($buffer, $result, $info);
 }
开发者ID:nemein,项目名称:com_meego_obsconnector,代码行数:38,代码来源:DebianPackagesParser.php


示例2: setLanguageFile

 private function setLanguageFile()
 {
     //filter language file
     $config = ParamesHelper::getLanguageConfig();
     $this->adminArray = preg_filter('/^/', $this->language . '.', $config['file_admin']);
     $this->siteArray = preg_filter('/^/', $this->language . '.', $config['file_site']);
     $site_list_file = JFolder::files($config['folder_site'] . $this->language);
     $this->itemsSite = MathHelper::filterArray($site_list_file, $this->siteArray);
     $admin_list_file = JFolder::files($config['folder_admin'] . $this->language);
     $this->itemsAdmin = MathHelper::filterArray($admin_list_file, $this->adminArray);
     return true;
 }
开发者ID:hixbotay,项目名称:executivetransport,代码行数:12,代码来源:view.html.php


示例3: __construct

 /**
  * Construct the driver with the configuration.
  *
  * @param ConfigurationInterface $configuration The configuration to be used.
  *
  * @throws \InvalidArgumentException If wrong configuration class received.
  */
 public function __construct(ConfigurationInterface $configuration)
 {
     // validate we get correct configuration class type.
     $type = (string) preg_filter('/Zikula\\\\Component\\\\FileSystem\\\\(\\w+)$/', '$1', get_class($this));
     $validName = "Zikula\\Component\\FileSystem\\Configuration\\{$type}Configuration";
     if ($validName != get_class($configuration)) {
         throw new \InvalidArgumentException(sprintf('Invalid configuration class for %1$s.  Expected %2$s but got %3$s instead. ::%4$s', get_class($this), $validName, get_class($configuration), $type));
     }
     $this->configuration = $configuration;
     $facade = "Zikula\\Component\\FileSystem\\Facade\\{$type}Facade";
     $this->driver = new $facade();
     $this->errorHandler = new Error();
 }
开发者ID:zikula,项目名称:filesystem,代码行数:20,代码来源:AbstractDriver.php


示例4: run

 /**
  * Runs the test case.
  * @return void
  */
 public function run($method = NULL)
 {
     $r = new \ReflectionObject($this);
     $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
         return $rm->getName();
     }, $r->getMethods())));
     if (substr($method, 0, 2) === '--') {
         // back compatibility
         $method = NULL;
     }
     if ($method === NULL && isset($_SERVER['argv']) && ($tmp = preg_filter('#(--method=)?([\\w-]+)$#Ai', '$2', $_SERVER['argv']))) {
         $method = reset($tmp);
         if ($method === self::LIST_METHODS) {
             Environment::$checkAssertions = FALSE;
             header('Content-Type: text/plain');
             echo '[' . implode(',', $methods) . ']';
             return;
         }
     }
     if ($method === NULL) {
         foreach ($methods as $method) {
             $this->runMethod($method);
         }
     } elseif (in_array($method, $methods, TRUE)) {
         $this->runMethod($method);
     } else {
         throw new TestCaseException("Method '{$method}' does not exist or it is not a testing method.");
     }
 }
开发者ID:jave007,项目名称:test,代码行数:33,代码来源:TestCase.php


示例5: iterateSubSelectors

 private function iterateSubSelectors($container, $payload)
 {
     $nodes = $this->crawler->filter($container);
     $results = array();
     $collect = function ($node, $i) use($payload, &$results) {
         $result = new \stdClass();
         foreach ($payload as $label => $selector) {
             if (is_string($selector)) {
                 $content = trim(strip_tags($node->filter($selector)->text()));
                 if ($label == "unit_price") {
                     $content = preg_filter(array("/£/", "/[a-z]/", "/\\//"), "", $content);
                 }
                 $result->{$label} = $content;
             } elseif (is_array($selector)) {
                 switch ($selector['type']) {
                     case "link":
                         $link = $node->filter($selector['context'])->link();
                         $nextPageCrawler = self::$goutte->click($link);
                         if ($selector['target'] == 'content_size') {
                             $result->{$label} = intval(ceil(strlen(self::$goutte->getResponse()->getContent()) / 1024));
                         } else {
                             $content = $nextPageCrawler->filter($selector['target']);
                             $result->{$label} = trim(strip_tags($content->text()));
                         }
                 }
             }
         }
         $results[] = $result;
     };
     $nodes->each($collect);
     return $results;
 }
开发者ID:ehalls,项目名称:sifter,代码行数:32,代码来源:Job.php


示例6: matches

 public function matches()
 {
     $url = $this->args;
     foreach ($this->routes as $args) {
         $path = preg_split('/\\//', $args['url']);
         $path = preg_filter('/\\w+/', '$0', $path);
         if (count($path) != count($url)) {
             continue;
         }
         $callback = function (array $matches) use($url, $path, &$args) {
             $key = array_search($matches[0], $path);
             if ($key !== false && array_key_exists($key, $url)) {
                 $find = array_search($matches[1], $args);
                 if ($find !== false && array_key_exists($find, $args)) {
                     $args[$find] = $url[$key];
                 }
                 return $url[$key];
             }
             return $matches[1];
         };
         $path = preg_replace_callback('/\\((.\\w+)\\)/', $callback, $path);
         $pattern = "^" . implode('\\/', $path);
         if (preg_match("/{$pattern}/", $this->request)) {
             if ($this->execute($args['controller'], $args['action'])) {
                 return $this;
             }
         }
     }
     throw new HTTP_Exception(404);
 }
开发者ID:Jurasikt,项目名称:bso,代码行数:30,代码来源:Route.php


示例7: parse

 protected static function parse($conf)
 {
     $routes = [];
     $curpos = [];
     foreach (explode("\n", $conf) as $line) {
         if (($pos = strpos($line, '#')) !== false) {
             $line = substr($line, 0, $pos);
         }
         if (!($line = rtrim($line))) {
             continue;
         }
         $depth = strlen(preg_filter('/^(\\s+).*/', '$1', $line));
         $data = preg_split('/\\s+/', ltrim($line));
         $path = $data[0];
         $node = $data[1] ?? null;
         $curpos = array_slice($curpos, 0, $depth);
         $curpos = array_pad($curpos, $depth, '');
         $curpos[] = $path;
         if (!$node) {
             continue;
         }
         $line = preg_replace('/^\\s*.*?\\s+/', '', $line);
         $path = preg_replace('/\\/+/', '/', '/' . join('/', $curpos));
         $node = preg_replace('/\\s*/', '', $line);
         $patt = str_replace('.', '\\.', $path);
         $patt = preg_replace('/:\\w+/', '([^/]+)', $patt);
         $patt = preg_replace('/@\\w+/', '(\\d+)', $patt);
         $class = preg_replace('/\\//', '\\controller\\', dirname($node), 1);
         $class = preg_replace('/\\//', '\\', $class);
         $routes[] = ['path' => $path, 'controller' => dirname($node), 'action' => basename($node), 'pattern' => $patt, 'class' => $class];
     }
     return $routes;
 }
开发者ID:tany,项目名称:php-note,代码行数:33,代码来源:Router.php


示例8: addParam

 public static function addParam($parameter, $params)
 {
     $params = preg_filter("/[\\{]?([^\\}]*)[\\}]?/si", "\$1", $params, 1);
     $values = explode(",", $params);
     $values[] = $parameter;
     return "{" . implode(",", $values) . "}";
 }
开发者ID:nicolasBREYNAERT,项目名称:helpdesk,代码行数:7,代码来源:Jquery.php


示例9: is_hello

 private function is_hello($str)
 {
     $a = $str . "q";
     $a = preg_filter("([^hello])", "", $a);
     $r = preg_filter(["(he)", "(2ll)", "([^3o])", "(3o)", "(o)"], ["2", "3", "", "4", ""], $a);
     return $r == "4" ? true : false;
 }
开发者ID:Qti3e,项目名称:ContestFramework,代码行数:7,代码来源:q4.php


示例10: blowfishHash

 public function blowfishHash($data, $cost = null, $alpha = null, $prefix = null)
 {
     if ($alpha !== null) {
         $alpha = preg_filter('/[^.\\/0-9a-z]/i', '', $alpha);
         if (strlen($alpha) > 22) {
             $alpha = substr($alpha, 0, 22);
         }
     }
     if ($prefix !== null) {
         switch ($prefix) {
             case '$2x$':
             case '$2y$':
                 break;
             case '$2a$':
                 $prefix = '$2x$';
                 break;
             case '$2$':
             default:
                 $prefix = null;
                 break;
         }
     }
     $salt = $this->blowfishSalt($cost, $alpha, $prefix);
     return crypt($data . $alpha, $salt['salt']);
 }
开发者ID:runeimp,项目名称:stf,代码行数:25,代码来源:Crypt.php


示例11: listing

 /**
  * Return array of diff files only
  *
  * Scans the specified directory, discards all found items
  * except files with the extension ".diff" and returns array with it.
  *
  * @param  string $dir
  * @return array
  */
 public function listing($dir)
 {
     $dir = empty($dir) || !is_dir($dir) ? realpath(__DIR__ . '/../') : $dir;
     $list = scandir($dir);
     $list = preg_filter('/.\\.diff$/i', '$0', $list);
     return $list;
 }
开发者ID:Vladimir-Voloshin,项目名称:simple_differ,代码行数:16,代码来源:DiffReaderClass.php


示例12: format

 /**
  * format()
  * Formata a mensagem recebida
  *
  * @version
  *     1.0 Initial
  *     
  * @param string $message Mensagem a ser formatada
  * @return string Mensagem formatada
  */
 public function format($message)
 {
     foreach ($this->patterns as $pattern => $replace) {
         preg_match($pattern, $message, $out);
     }
     return preg_filter(array_keys($this->patterns), array_values($this->patterns), $message);
 }
开发者ID:klawdyo,项目名称:spaghetti-lib,代码行数:17,代码来源:TwitterHelper.php


示例13: testSimpleLambda

 public function testSimpleLambda()
 {
     $lambdaFunc = function ($word) {
         return preg_filter("/my/i", "", $word);
     };
     $stemmer = new LambdaStemmer($lambdaFunc);
     $this->assertEquals("tom", $stemmer->stem("tommy"));
 }
开发者ID:WHATNEXTLIMITED,项目名称:php-text-analysis,代码行数:8,代码来源:LambdaStemmerTest.php


示例14: __call

 public function __call($name, $parameters)
 {
     if (preg_match('/Complete$/', $name)) {
         $name = preg_filter('/Complete$/', '', $name);
         return $this->_Complete($name, $parameters);
     }
     return $this->_callFunction($name, $parameters);
 }
开发者ID:bruno-melo,项目名称:components,代码行数:8,代码来源:MyActiveForm.php


示例15: _preg_filter

 /**
  * Perform a regular expression search and replace, returning only matched subjects.
  *
  * @param string $subject
  * @param string $pattern
  * @param string $replacement
  * @param int    $limit
  *
  * @return string
  */
 public function _preg_filter($subject, $pattern, $replacement = '', $limit = -1)
 {
     if (!isset($subject)) {
         return;
     } else {
         return preg_filter($pattern, $replacement, $subject, $limit);
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:18,代码来源:PcreExtension.php


示例16: testLambdaPregFilter

 public function testLambdaPregFilter()
 {
     $lambda = function ($word) {
         return preg_filter("/bob/", "tom", $word);
     };
     $transformer = new LambdaFilter($lambda);
     $this->assertEquals("tomtom", $transformer->transform("bobbob"));
 }
开发者ID:WHATNEXTLIMITED,项目名称:php-text-analysis,代码行数:8,代码来源:LambdaFilterTest.php


示例17: getCssEmbedCode

 public static function getCssEmbedCode($username, $css_url = null)
 {
     if (!$css_url) {
         $css_url = self::STYLA_URL;
     }
     $sCssUrl = preg_filter('/https?:(.+)/i', '$1', rtrim($css_url, '/') . '/') . 'styles/clients/' . $username . '.css?version=' . self::_getVersion($username);
     return '<link rel="stylesheet" type="text/css" href="' . $sCssUrl . '">';
 }
开发者ID:styladev,项目名称:oxid,代码行数:8,代码来源:StylaSEO_Util.php


示例18: getPrincipalByPath

 public function getPrincipalByPath($path)
 {
     $user = new Phprojekt_User_User();
     $user = $user->findByUsername(preg_filter('|.*principals/([^/]+)$|', '$1', $path));
     if (is_null($user)) {
         throw new Exception("Principal not found for path {$path}");
     }
     return array('id' => $user->id, 'uri' => "principals/{$user->username}", '{DAV:}displayname' => $user->username, '{http://sabredav.org/ns}email-address' => $user->getSetting('email'));
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:9,代码来源:PrincipalBackend.php


示例19: getCalendarsForUser

 /**
  * Implements getCalendarsForUser from Sabre_CalDAV_Backend_Abstract
  *
  * This is simplified for PHProjekt. We only have one calendar per user, so we return hard-coded data based on the
  * user name. The id of the calendar is the id of the user it belongs to.
  *
  * @param string $principalUri The uri of the user whose calendar to get
  *
  * @return array calendar description
  */
 public function getCalendarsForUser($principalUri)
 {
     // We have exactly one calendar per principal.
     $user = new Phprojekt_User_User();
     $user = $user->findByUsername(preg_filter('|.*principals/([^/]+)$|', '$1', $principalUri));
     if (is_null($user)) {
         throw new Exception("principal not found under {$principalUri} when retrieving calendars for {$username}");
     }
     return array(array('id' => $user->id, 'uri' => 'default', 'principaluri' => $principalUri, '{DAV:}displayname' => 'default', '{http://apple.com/ns/ical/}calendar-color' => 'blue', '{http://apple.com/ns/ical/}calendar-order' => 0, '{' . Sabre_CalDAV_Plugin::NS_CALENDARSERVER . '}getctag' => time(), '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT'))));
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:20,代码来源:CalendarBackend.php


示例20: addAction

 /**
  * Parses and adds a controller action
  *
  * @param string $actionName
  *
  * @return
  */
 private function addAction($actionName)
 {
     $template = $this->templates[$actionName];
     $command = preg_filter('/^/', '    ', explode(PHP_EOL, strtr($template, ['$actionName' => $actionName])));
     $command = array_filter($command, function ($var) {
         return strlen(trim($var));
     });
     $command = implode(PHP_EOL, $command);
     $this->commands[] = $command;
 }
开发者ID:slimphp-api,项目名称:slim-mvc,代码行数:17,代码来源:ControllerService.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP preg_grep函数代码示例发布时间:2022-05-15
下一篇:
PHP preg_files函数代码示例发布时间: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