当前位置: 首页>>代码示例>>PHP>>正文


PHP last函数代码示例

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


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

示例1: getPathArgumentForLinterFuture

 protected function getPathArgumentForLinterFuture($path)
 {
     $full_path = Filesystem::resolvePath($path);
     $ret = array($full_path);
     // The |path| we get fed needs to be made relative to the project_root,
     // otherwise the |engine| won't recognise it.
     $relative_path = Filesystem::readablePath($full_path, $this->getProjectRoot());
     $changed = $this->getEngine()->getPathChangedLines($relative_path);
     if ($changed !== null) {
         // Convert the ordered set of changed lines to a list of ranges.
         $changed_lines = array_keys(array_filter($changed));
         $ranges = array(array($changed_lines[0], $changed_lines[0]));
         foreach (array_slice($changed_lines, 1) as $line) {
             $range = last($ranges);
             if ($range[1] + 1 === $line) {
                 ++$range[1];
                 $ranges[last_key($ranges)] = $range;
             } else {
                 $ranges[] = array($line, $line);
             }
         }
         foreach ($ranges as $range) {
             $ret[] = sprintf('--lines=%d:%d', $range[0], $range[1]);
         }
     }
     return csprintf('%Ls', $ret);
 }
开发者ID:nickhutchinson,项目名称:morefas-phabricator,代码行数:27,代码来源:FnClangFormatLinter.php

示例2: __construct

 /**
  *
  * @param String $file
  * @throws \Exception
  */
 public function __construct($file)
 {
     $this->_position = 0;
     if (is_array($file) && strlen(rtrim($file[0], chr(10) . chr(13) . "\n" . "\r")) == 400) {
         $this->file = $file;
     } else {
         if (is_file($file) && file_exists($file)) {
             $this->file = file($file);
         } else {
             if (is_string($file)) {
                 $this->file = preg_split('/\\r\\n|\\r|\\n/', $file);
                 if (empty(last($this->file))) {
                     array_pop($this->file);
                 }
             } else {
                 throw new \Exception("Arquivo: não existe");
             }
         }
     }
     $this->isRetorno = substr($this->file[0], 0, 9) == '02RETORNO' ? true : false;
     if (!in_array(substr($this->file[0], 76, 3), array_keys($this->bancos))) {
         throw new \Exception(sprintf("Banco: %s, inválido", substr($this->file[0], 76, 3)));
     }
     $this->header = new Header();
     $this->trailer = new Trailer();
 }
开发者ID:jhonleandres,项目名称:laravel-boleto,代码行数:31,代码来源:AbstractCnab.php

示例3: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhabricatorMetaMTAApplicationEmailTransaction::TYPE_ADDRESS:
             foreach ($xactions as $xaction) {
                 $email = $xaction->getNewValue();
                 if (!strlen($email)) {
                     // We'll deal with this below.
                     continue;
                 }
                 if (!PhabricatorUserEmail::isValidAddress($email)) {
                     $errors[] = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('Email address is not formatted properly.'));
                 }
             }
             $missing = $this->validateIsEmptyTextField($object->getAddress(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('You must provide an email address.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
     }
     return $errors;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:25,代码来源:PhabricatorMetaMTAApplicationEmailEditor.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     $user = new User();
     $user->username = 'superadmin';
     $user->email = 'superadmin@superadmin.com';
     $user->password = 'superadmin';
     $user->password_confirmation = 'superadmin';
     $user->confirmed = 1;
     $user->profile_photo = $faker->imageUrl($width = 198, $height = 198);
     $fullname = explode(" ", $faker->name);
     $surname = last($fullname);
     unset($fullname[count($fullname) - 1]);
     $name = implode(" ", $fullname);
     $user->name = $name;
     $user->surname = $surname;
     $user->save();
     $user = new User();
     $user->username = 'admin';
     $user->email = 'admin@admin.com';
     $user->password = 'admin';
     $user->password_confirmation = 'admin';
     $user->confirmed = 1;
     $user->profile_photo = $faker->imageUrl($width = 198, $height = 198);
     $fullname = explode(" ", $faker->name);
     $surname = last($fullname);
     unset($fullname[count($fullname) - 1]);
     $name = implode(" ", $fullname);
     $user->name = $name;
     $user->surname = $surname;
     $user->save();
 }
开发者ID:kadirarli,项目名称:laravel-self,代码行数:32,代码来源:UsersTableSeeder.php

示例5: curl_run

 protected function curl_run($comicId, $onlineId)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->comic_url . $onlineId . "/");
     curl_setopt($ch, CURLOPT_HEADER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $output = curl_exec($ch);
     $matchArr = [];
     //$output = '<a href="http://8yyls.com/20579">第154話</a>' . '<a href="http://8yyls.com/20375">第004卷</a>';
     preg_match_all("/http:\\/\\/8yyls\\.com\\/[0-9]+[\\/]?\">第[0-9]+(卷|話)/", $output, $matchArr, PREG_OFFSET_CAPTURE);
     $maxNum = last($matchArr[0]);
     $result = [];
     $result = explode('">第', $maxNum[0]);
     $book = \App\Books::where('comics_id', $comicId)->first();
     if ($book === null) {
         $book = new \App\Books();
         $book->comics_id = $comicId;
         $book->link = $result[0];
         $book->chapter = substr($result[1], 0, 3);
         $book->is_read = false;
         $book->save();
     } else {
         if ($book->chapter !== substr($result[1], 0, 3)) {
             $book->link = $result[0];
             $book->chapter = substr($result[1], 0, 3);
             $book->is_read = false;
             $book->save();
         }
     }
     /** finished curl not test */
     curl_close($ch);
 }
开发者ID:e19940604,项目名称:comicReminder,代码行数:32,代码来源:comicUpdateCommand.php

示例6: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhamePostTransaction::TYPE_TITLE:
             $missing = $this->validateIsEmptyTextField($object->getTitle(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Title is required.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhamePostTransaction::TYPE_BLOG:
             if ($this->getIsNewObject()) {
                 if (!$xactions) {
                     $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('When creating a post, you must specify which blog it ' . 'should belong to.'), null);
                     $error->setIsMissingFieldError(true);
                     $errors[] = $error;
                     break;
                 }
             }
             foreach ($xactions as $xaction) {
                 $new_phid = $xaction->getNewValue();
                 $blog = id(new PhameBlogQuery())->setViewer($this->getActor())->withPHIDs(array($new_phid))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
                 if ($blog) {
                     continue;
                 }
                 $errors[] = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('The specified blog PHID ("%s") is not valid. You can only ' . 'create a post on (or move a post into) a blog which you ' . 'have permission to see and edit.', $new_phid), $xaction);
             }
             break;
     }
     return $errors;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:33,代码来源:PhamePostEditor.php

示例7: validateTransaction

 protected function validateTransaction(PhabricatorLiskDAO $object, $type, array $xactions)
 {
     $errors = parent::validateTransaction($object, $type, $xactions);
     switch ($type) {
         case PhortuneAccountTransaction::TYPE_NAME:
             $missing = $this->validateIsEmptyTextField($object->getName(), $xactions);
             if ($missing) {
                 $error = new PhabricatorApplicationTransactionValidationError($type, pht('Required'), pht('Account name is required.'), nonempty(last($xactions), null));
                 $error->setIsMissingFieldError(true);
                 $errors[] = $error;
             }
             break;
         case PhabricatorTransactions::TYPE_EDGE:
             foreach ($xactions as $xaction) {
                 switch ($xaction->getMetadataValue('edge:type')) {
                     case PhortuneAccountHasMemberEdgeType::EDGECONST:
                         // TODO: This is a bit cumbersome, but validation happens before
                         // transaction normalization. Maybe provide a cleaner attack on
                         // this eventually? There's no way to generate "+" or "-"
                         // transactions right now.
                         $new = $xaction->getNewValue();
                         $set = idx($new, '=', array());
                         if (empty($set[$this->requireActor()->getPHID()])) {
                             $error = new PhabricatorApplicationTransactionValidationError($type, pht('Invalid'), pht('You can not remove yourself as an account member.'), $xaction);
                             $errors[] = $error;
                         }
                         break;
                 }
             }
             break;
     }
     return $errors;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhortuneAccountEditor.php

示例8: renderObjectEmbed

 protected function renderObjectEmbed($object, $handle, $options)
 {
     $embed_paste = id(new PasteEmbedView())->setPaste($object)->setHandle($handle);
     if (strlen($options)) {
         $parser = new PhutilSimpleOptions();
         $opts = $parser->parse(substr($options, 1));
         foreach ($opts as $key => $value) {
             if ($key == 'lines') {
                 $embed_paste->setLines(preg_replace('/[^0-9]/', '', $value));
             } else {
                 if ($key == 'highlight') {
                     $highlights = preg_split('/,|&/', preg_replace('/\\s+/', '', $value));
                     $to_highlight = array();
                     foreach ($highlights as $highlight) {
                         $highlight = explode('-', $highlight);
                         if (!empty($highlight)) {
                             sort($highlight);
                             $to_highlight = array_merge($to_highlight, range(head($highlight), last($highlight)));
                         }
                     }
                     $embed_paste->setHighlights(array_unique($to_highlight));
                 }
             }
         }
     }
     return $embed_paste;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:27,代码来源:PhabricatorPasteRemarkupRule.php

示例9: run

 public function run()
 {
     DB::table('categories')->delete();
     $jsonCat = json_decode(file_get_contents(url('/categories.json')));
     foreach ($jsonCat as $categoriesParent) {
         $cat = new Category();
         $cat->title = $categoriesParent->title;
         $cat->slug = last(explode('/', $categoriesParent->slug));
         $cat->save();
         foreach ($categoriesParent->children as $catChild1) {
             $cat1 = new Category();
             $cat1->title = $catChild1->title;
             $cat1->slug = last(explode('/', $catChild1->slug));
             $cat1->parent_id = $cat->id;
             $cat1->save();
             foreach ($catChild1->children as $catChild2) {
                 $cat2 = new Category();
                 $cat2->title = $catChild2->title;
                 $cat2->slug = last(explode('/', $catChild2->slug));
                 $cat2->parent_id = $cat1->id;
                 $cat2->save();
             }
         }
     }
 }
开发者ID:leoxopow,项目名称:dmtoys,代码行数:25,代码来源:DatabaseSeeder.php

示例10: show

 /**
  * Display the specified 3-week calendar.
  *
  * @param  int  $date
  * @return \Illuminate\Http\Response
  */
 public function show($date)
 {
     $datelist = $this->getDateList($date);
     $visits = Visit::with('place')->where('date', '>=', head($datelist))->where('date', '<=', last($datelist))->get();
     $visits = $visits->keyBy('date');
     return view('calendar.index', compact('visits', 'datelist'));
 }
开发者ID:vybeauregard,项目名称:lunch,代码行数:13,代码来源:CalendarController.php

示例11: links

 public function links()
 {
     $params = [];
     $list = [];
     $extras = [];
     $new_list_length = null;
     if (is_array(last($this->route_params))) {
         $extras = array_pop($this->route_params);
     }
     $append_plain = $this->getPlainTextExtras($extras, 'append_plain', $this->items);
     $prepend_plain = $this->getPlainTextExtras($extras, 'prepend_plain', $this->items);
     foreach ($this->route_params as $param) {
         $params[] = $this->collectKeys($this->items, $param)->toArray();
     }
     $items = $this->collectKeys($this->items, $this->key);
     if (array_key_exists('truncate', $extras)) {
         $this->setCharLimit($extras['truncate']);
         $new_list_length = $this->getTruncatedList($items);
         $this->setCharLimit(null);
     }
     foreach ($items as $key => $item) {
         $str = '';
         if ($str_prepend = $this->getPlainTextReplaced($extras, 'prepend_plain', $prepend_plain, $key)) {
             $str .= $str_prepend;
         }
         $str .= '<a href="' . route($this->route, array_fetch($params, $key)) . '">';
         $str .= $item . '</a>';
         if ($str_append = $this->getPlainTextReplaced($extras, 'append_plain', $append_plain, $key)) {
             $str .= $str_append;
         }
         $list[] = $str;
     }
     return $this->listize($list, $new_list_length);
 }
开发者ID:ngangchill,项目名称:templater,代码行数:34,代码来源:ItemList.php

示例12: postUpload

 public function postUpload($relation_id, $ref_id)
 {
     //
     $file = Input::file('imagem');
     //
     $validator = Validator::make(['imagem' => $file], ['imagem' => 'required|mimes:jpeg,bmp,png|max:5000']);
     if ($validator->fails()) {
         $errors = $validator->errors();
         return response()->json(['error' => true, 'message' => $errors->first('file_image')]);
     }
     //
     $this->destroy($relation_id, $ref_id);
     //
     $img = Image::make($file);
     //
     $image = new ImageModel();
     $image->position = 0;
     $image->ref_id = $ref_id;
     $image->relation_id = $relation_id;
     $image->type = last(explode('/', $img->mime()));
     $image->save();
     //
     $img->save($image->getPath());
     //
     return response()->json(['error' => false, 'message' => 'Imagem enviada com sucesso!']);
 }
开发者ID:eliasrosa,项目名称:bw-core,代码行数:26,代码来源:ImageApiController.php

示例13: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer(['front.header', 'admin.header'], function ($view) {
         $languages = [];
         $folders = File::directories(base_path('resources/lang/'));
         foreach ($folders as $folder) {
             $languages[] = str_replace('\\', '', last(explode('/', $folder)));
         }
         $view->with('languages', $languages);
     });
     view()->composer('front.header', function ($view) {
         $apps = Application::all();
         $view->with('apps', $apps);
     });
     view()->composer('admin.news.form', function ($view) {
         $categories = ['update' => trans('news.category.update'), 'maintenance' => trans('news.category.maintenance'), 'event' => trans('news.category.event'), 'contest' => trans('news.category.contest'), 'other' => trans('news.category.other')];
         $view->with('categories', $categories);
     });
     view()->composer('front.widgets', function ($view) {
         $client_status = @fsockopen(settings('server_ip', '127.0.0.1'), 6543, $errCode, $errStr, 1) ? TRUE : FALSE;
         $worlds = DB::connection('account')->table('worlds')->get();
         $view->with('client_status', $client_status)->with('worlds', $worlds);
     });
     view()->composer('admin.donate.settings', function ($view) {
         $view->with('currencies', trans('donate.currency'));
     });
 }
开发者ID:huludini,项目名称:aura-kingdom-web,代码行数:32,代码来源:ViewServiceProvider.php

示例14: peekWorkingDirectory

 public function peekWorkingDirectory()
 {
     if ($this->workingDirectoryStack) {
         return last($this->workingDirectoryStack);
     }
     return null;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:DrydockCommandInterface.php

示例15: newBranchFromCommit

 public function newBranchFromCommit(PhabricatorRepositoryCommit $cut_point, $branch_date, $symbolic_name = null)
 {
     $template = $this->releephProject->getDetail('branchTemplate');
     if (!$template) {
         $template = ReleephBranchTemplate::getRequiredDefaultTemplate();
     }
     $cut_point_handle = id(new PhabricatorHandleQuery())->setViewer($this->requireActor())->withPHIDs(array($cut_point->getPHID()))->executeOne();
     list($name, $errors) = id(new ReleephBranchTemplate())->setCommitHandle($cut_point_handle)->setBranchDate($branch_date)->setReleephProjectName($this->releephProject->getName())->interpolate($template);
     $basename = last(explode('/', $name));
     $table = id(new ReleephBranch());
     $transaction = $table->openTransaction();
     $branch = id(new ReleephBranch())->setName($name)->setBasename($basename)->setReleephProjectID($this->releephProject->getID())->setCreatedByUserPHID($this->requireActor()->getPHID())->setCutPointCommitPHID($cut_point->getPHID())->setIsActive(1)->setDetail('branchDate', $branch_date)->save();
     /**
      * Steal the symbolic name from any other branch that has it (in this
      * project).
      */
     if ($symbolic_name) {
         $others = id(new ReleephBranch())->loadAllWhere('releephProjectID = %d', $this->releephProject->getID());
         foreach ($others as $other) {
             if ($other->getSymbolicName() == $symbolic_name) {
                 $other->setSymbolicName(null)->save();
             }
         }
         $branch->setSymbolicName($symbolic_name)->save();
     }
     $table->saveTransaction();
     return $branch;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:28,代码来源:ReleephBranchEditor.php


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