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

PHP first函数代码示例

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

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



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

示例1: retrieve

 /**
  * Retrieve request specified by id argument, if second argument is specified, array of requests from id to last
  * will be returned
  */
 public function retrieve($id = null, $last = null)
 {
     if ($id && !$last) {
         if (!is_readable($this->path . '/' . $id . '.json')) {
             return null;
         }
         return new Request(json_decode(file_get_contents($this->path . '/' . $id . '.json'), true));
     }
     $files = glob($this->path . '/*.json');
     $id = $id ? $id . '.json' : first($files);
     $last = $last ? $last . '.json' : end($files);
     $requests = array();
     $add = false;
     foreach ($files as $file) {
         if ($file == $id) {
             $add = true;
         } elseif ($file == $last) {
             $add = false;
         }
         if (!$add) {
             continue;
         }
         $requests[] = new Request(json_decode(file_get_contents($file), true));
     }
     return $requests;
 }
开发者ID:iamsamitdev,项目名称:modalapp,代码行数:30,代码来源:FileStorage.php


示例2: get

 /**
  * Retrieve request specified by id argument, if second argument is specified, array of requests from id to last
  * will be returned
  */
 public function get($id = null, $last = null)
 {
     if ($id && !$last) {
         if (!is_readable($this->path . '/' . $id . $this->extension)) {
             return null;
         }
         return new Request(unserialize(file_get_contents($this->path . '/' . $id . $this->extension), true));
     }
     $files = glob($this->path . '/*' . $this->extension);
     $id = $id ? $id . $this->extension : first($files);
     $last = $last ? $last . $this->extension : end($files);
     $requests = array();
     $add = false;
     foreach ($files as $file) {
         if ($file == $id) {
             $add = true;
         } elseif ($file == $last) {
             $add = false;
         }
         if (!$add) {
             continue;
         }
         $requests[] = new Request(unserialize(file_get_contents($file), true));
     }
     return $requests;
 }
开发者ID:onigoetz,项目名称:profiler,代码行数:30,代码来源:FileStorage.php


示例3: update

	public function update($tmpDir = '') {
		Helper::mkdir($tmpDir, true);
		$this->collect();
		try {
			foreach ($this->appsToUpdate as $appId) {
				if (!@file_exists($this->newBase . '/' . $appId)){
					continue;
				}
				$path = \OC_App::getAppPath($appId);
				if ($path) {
					Helper::move($path, $tmpDir . '/' . $appId);
					
					// ! reverted intentionally
					$this->done [] = array(
						'dst' => $path,
						'src' => $tmpDir . '/' . $appId
					);
					
					Helper::move($this->newBase . '/' . $appId, $path);
				} else { 
					// The app is new and doesn't exist in the current instance
					$pathData = first(\OC::$APPSROOTS);
					Helper::move($this->newBase . '/' . $appId, $pathData['path'] . '/' . $appId);
				}
			}
			$this->finalize();
		} catch (\Exception $e) {
			$this->rollback(true);
			throw $e;
		}
	}
开发者ID:BacLuc,项目名称:newGryfiPage,代码行数:31,代码来源:apps.php


示例4: third

function third()
{
    enter_function('third');
    second();
    first();
    exit_function();
}
开发者ID:JohnWSteill,项目名称:EdProjs,代码行数:7,代码来源:05_5.php


示例5: getEventsByTarget

 static function getEventsByTarget($deviceDS)
 {
     $where = array('e_code LIKE ?', 'e_code LIKE ?', 'e_code LIKE ?');
     $searchPatterns = array('%' . $deviceDS['d_id'] . '%', '%' . @first($deviceDS['d_alias'], 'NOMATCH') . '%');
     return o(db)->get('SELECT * FROM #events WHERE
     ' . implode(' OR ', $where), $searchPatterns);
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:7,代码来源:H2EventManager.php


示例6: sendForgetMail

 /**
  * send forget mail to user
  *
  * @param array $parameters
  * @param string $column
  * @return mixed
  * @throws OAuthException
  * @throws QueryException
  */
 protected function sendForgetMail(array $parameters = [], $column = null)
 {
     $username = isset($parameters['username']) ? $parameters['username'] : '';
     $mailDriver = isset($parameters['mail_driver']) ? $parameters['mail_driver'] : 'default';
     $callback = isset($parameters['callback']) ? $parameters['callback'] : 'auth/forget';
     $table = Config::get('database.tables.table');
     $database = Database::table($table);
     $userColumn = null === $column ? first(Config::get('database.tables.login')) : $column;
     $userInformation = $database->select(['email', 'id'])->where($userColumn, $username);
     if (!$userInformation->rowCount()) {
         throw new OAuthException(sprintf('%s Username is not exists', $username));
     }
     $datas = $userInformation->first();
     // we will find user email now
     $mailAddress = $datas->email;
     $generator = new SecurityKeyGenerator();
     $key = $generator->random($username . $mailAddress);
     $forgets = Database::table('forgets');
     $add = $forgets->insert(['key' => $key, 'user_id' => $datas->id]);
     if (!$add->isSuccess()) {
         throw new QueryException('Forget keys and user_id could not added to database, please try agein later');
     }
     $url = Request::getBaseWithoutQuery();
     if (!Str::endsWith($callback, "/")) {
         $callback .= "/";
     }
     $url .= $callback . $key;
     $template = new TemplateGenerator(file_get_contents(RESOURCE . 'migrations/forget_mail.php.dist'));
     $content = $template->generate(['url' => $url, 'username' => $username]);
     $yourAddress = config('mail.your_address');
     $send = Mail::send($mailDriver, function (DriverInterface $mail) use($mailAddress, $username, $content, $yourAddress) {
         return $mail->from($yourAddress, '')->subject('Password Recovery')->to($mailAddress, $username)->body($content)->send();
     });
     return $send;
 }
开发者ID:AnonymPHP,项目名称:AnonymFramework,代码行数:44,代码来源:AuthController.php


示例7: head

/**
 * Alias for Functional\first
 *
 * @param Traversable|array $collection
 * @param callable $callback
 * @return mixed
 */
function head($collection, $callback = null)
{
    Exceptions\InvalidArgumentException::assertCollection($collection, __FUNCTION__, 1);
    if ($callback !== null) {
        Exceptions\InvalidArgumentException::assertCallback($callback, __FUNCTION__, 2);
    }
    return first($collection, $callback);
}
开发者ID:reeze,项目名称:functional-php,代码行数:15,代码来源:Head.php


示例8: reduce

function reduce(callable $fn, $sq)
{
    $sq = is_array($sq) ? $sq : iterator_to_array($sq);
    $r = first($sq);
    for ($i = 0; $i < count($sq) - 1; $i++) {
        $r = $fn($r, $sq[$i + 1]);
    }
    return $r;
}
开发者ID:sergigp,项目名称:funiculus,代码行数:9,代码来源:funiculus.php


示例9: crearNumeroUnico

 /**
  * funciones de negocio
  */
 public function crearNumeroUnico()
 {
     $numero_unico = str_random(10);
     $busqueda = $this->where('numero_unico', '=', $numero_unico) - first();
     if (!is_null($busqueda)) {
         return $numero_unico;
     } else {
         $this->crearNumeroUnico();
     }
 }
开发者ID:AndresRojasIsaza,项目名称:Delivery,代码行数:13,代码来源:Cuenta.php


示例10: setSabbaticalData

function setSabbaticalData($data)
{
    $sabbatical = (object) [];
    $sabbatical->date = $data[9];
    $sabbatical->location = ['latitude' => $data[3], 'longitude' => $data[4], 'city' => first($data[2]), 'country' => last($data[2])];
    $sabbatical->organization = ['title' => $data[5], 'website' => $data[8]];
    $sabbatical->contact = ['name' => $data[6], 'email' => $data[7]];
    $sabbatical->description = $data[10];
    return $sabbatical;
}
开发者ID:DoSomething,项目名称:carmen,代码行数:10,代码来源:import.php


示例11: invokeAction

 function invokeAction($action)
 {
     $_REQUEST['action'] = basename(first($action, 'index'));
     ob_start();
     $this->controller->invokeAction($_REQUEST['action'], $this->params);
     $this->controller->lastAction = $_REQUEST['action'];
     $this->actionOutput = trim(ob_get_clean());
     profile_point('H2Dispatcher.invokeAction(' . $_REQUEST['action'] . ')');
     return $this;
 }
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:10,代码来源:H2Dispatcher.php


示例12: create

 public static function create($msg, $type = E_USER_NOTICE)
 {
     if (in_array($type, Config::get('error.levels'))) {
         // Throw an actual error.
         $callee = first(debug_backtrace());
         trigger_error($msg . ' in <strong>' . $callee['file'] . '</strong> on line <strong>' . $callee['line'] . "</strong>.\n<br> Thrown", $type);
         self::log($msg);
         return true;
     }
     return false;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:11,代码来源:error.php


示例13: boot

 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     $listens = $this->listen;
     $this->listen = array_merge($this->listen, $this->listen_eloquent);
     parent::boot($events);
     $events->listen('eloquent.*', function ($model) use($events) {
         $event_type = first(explode(': ', last(explode('.', $events->firing()))));
         $event = get_class($model) . '::' . $event_type;
         return $events->fire($event, $model);
     });
     $this->listen = $listens;
 }
开发者ID:CupOfTea696,项目名称:CardsAgainstTea,代码行数:18,代码来源:EventServiceProvider.php


示例14: run

 /**
  * Migration sınıfını yürütür
  * @param string $fileName
  * @return array
  */
 public function run($fileName)
 {
     $return = [];
     if ('' !== $fileName) {
         $return = [$this->execute($fileName)];
     } else {
         $list = Finder::create()->files()->name('*.php')->in(MIGRATION);
         foreach ($list as $l) {
             $return[] = $this->execute(first(explode('.', $l->getFilename())));
         }
     }
     return $return;
 }
开发者ID:AnonymPHP,项目名称:Anonym-Database-Tools,代码行数:18,代码来源:MigrationManager.php


示例15: __call

 public function __call($method, $args)
 {
     //  If there's a method, call it
     if (method_exists($this->_class, $method)) {
         $call = call_user_func_array(array($this->_class, $method), $args);
         //  Don't chain if it returns something
         if (!is_null($call)) {
             return $call;
         }
     } else {
         //  Otherwise, just set it manually
         $this->_class->set($method, first($args));
     }
     return $this;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:15,代码来源:email.php


示例16: cfg

function cfg($name, $default = null, $set = false)
{
    $vr =& $GLOBALS['config'];
    foreach (explode('/', $name) as $ni) {
        if (is_array($vr)) {
            $vr =& $vr[$ni];
        } else {
            $vr = '';
        }
    }
    if ($set) {
        $vr = $default;
    }
    return first($vr, $default);
}
开发者ID:bangnaga,项目名称:HomeOverlord,代码行数:15,代码来源:h2config.php


示例17: common_title

function common_title()
{
    $picked = null;
    $route = Request::route();
    if ($route) {
        $routeName = $route->getName();
        $page = Lang::get("pages.{$routeName}");
        if ($page != $routeName) {
            $picked = $page;
        }
    }
    if ($picked == null) {
        $picked = Lang::get('pages.home');
    }
    return is_array($picked) ? @$picked['index'] ?: first($picked) : $picked;
}
开发者ID:ankhzet,项目名称:Ankh,代码行数:16,代码来源:view.php


示例18: render

 /**
  * Render the requested view by calling methods on the controller subclass
  * including "before", the view method, "after", then rendering view data.
  *
  * @param String $view the name of the view to render
  * @param Array $options rendering options (e.g. "type" to set content type)
  * @return String the content to display in the response to the client
  */
 public function render($view = NULL, $options = array())
 {
     // Get the view (e.g. "index") and the type (e.g. "html")
     $this->view = first($view, $this->view);
     $this->type = first(array_key($options, 'type'), $this->type, $this->app->get_content_type());
     // Call the controller's view method
     $this->before();
     $method = strtr($this->view, '-', '_');
     if (method_exists($this, $method)) {
         $this->{$method}();
     }
     $this->after();
     // Render the view with a data array
     $this->render->content = $this->app->render_view($this->view, $this->render, $options);
     return $this->app->render_type($this->type, $this->render);
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:24,代码来源:Controller.php


示例19: register

 /**
  * register the provider
  *
  * @return mixed
  */
 public function register()
 {
     Paginator::setCurrentPageFinder(function () {
         if (isset($_GET['page'])) {
             $page = first(GUMP::xss_clean([$_GET['page']]));
             return $page;
         } else {
             return 1;
         }
     });
     $request = App::make('http.request');
     Paginator::setRequestPathFinder(function () use($request) {
         if ($request instanceof Request) {
             return $request->getBaseWithoutQuery();
         }
     });
 }
开发者ID:AnonymPHP,项目名称:Anonym-Database,代码行数:22,代码来源:PaginationServiceProvider.php


示例20: parse

 public function parse($template)
 {
     $vars = self::$vars;
     $vars['_alnum'] = 'a-zA-Z0-9_';
     //  Replace {{variables}}
     $template = preg_replace_callback('/{{([' . $vars['_alnum'] . ']+)(\\/[' . $vars['_alnum'] . ' \\.,+\\-\\/!\\?]+)?}}/', function ($matches) use($vars) {
         if (count($matches) === 3) {
             $matches[1] = $matches[1] . '/' . $matches[2];
             unset($matches[2]);
         }
         //  Discard the first match, and check for fallbacks
         $matches = explode('/', last($matches));
         //  There will always be a first key
         $match = first($matches);
         //  Set the fallback value, if it exists
         $fallback = isset($matches[1]) ? $matches[1] : '';
         //  Return matching variables, if they exist
         //  AND are not null or empty-ish
         if (isset($vars[$match])) {
             return $vars[$match];
         }
         //  Try a fallback
         return $fallback;
     }, $template);
     //  [conditionals][/conditionals]
     $template = preg_replace_callback('/(\\[[\\!?' . $vars['_alnum'] . ']+\\])(.*?\\[\\/[' . $vars['_alnum'] . ']+\\])/s', function ($matches) use($vars) {
         $match = str_replace(array('[', ']'), '', $matches[1]);
         $cond = isset($vars[$match]) and !empty($vars[$match]);
         //  [!inverse][/inverse]
         if (strpos($match, '!') !== false) {
             $match = str_replace('!', '', $match);
             $cond = !isset($vars[$match]) or empty($vars[$match]);
         }
         if ($cond !== false) {
             return trim(preg_replace('/\\[[\\/!]?' . $match . '\\]/', '', $matches[0]));
         }
         return '';
     }, $template);
     //  Include partials (~partial~)
     $template = preg_replace_callback('/~([' . $vars['_alnum'] . ']+)~/', function ($matches) use($vars) {
         return grab(APP_BASE . 'partials/' . preg_replace('/[^' . $vars['_alnum'] . ']+/', '', $matches[0]) . '.php', $vars);
     }, $template);
     return $template;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:44,代码来源:template.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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