本文整理汇总了PHP中last函数的典型用法代码示例。如果您正苦于以下问题:PHP last函数的具体用法?PHP last怎么用?PHP last使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了last函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 = '[email protected]';
$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 = '[email protected]';
$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
示例16: parse_template
function parse_template($string)
{
# Don't mess with the $stack/$tem assignments! Since
# PHP references point to the variable, not the data,
# it really does have to be written exactly like this.
$stack[] = array();
$tem =& last($stack);
# note: for some reason this captures '<!--' but not '-->'.
$pieces = preg_split("/(<!--)?(~[^~]*~)(?(1)-->)/", $string, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($pieces as $piece) {
if ($piece[0] == '~') {
$tag = preg_replace('/~([^?.]*)[?.]?~/', "\$1", $piece);
$last = substr($piece, -2, 1);
if ($last == '?') {
$stack[] = array($tag);
$tem[] =& last($stack);
$tem =& last($stack);
} elseif ($last == '.') {
$cur = $stack[count($stack) - 1][0];
if ($tag && $tag != $cur) {
die("Invalid template: tried to close '{$tag}', but '{$cur}' is current.");
}
array_pop($stack);
$tem =& last($stack);
} else {
$tem[] = array($tag);
}
} elseif ($piece and $piece != '<!--') {
$tem[] = $piece;
}
}
return $tem;
}
开发者ID:JoshuaGrams,项目名称:wfpl,代码行数:33,代码来源:template.php
示例17: wrap
static function wrap($name, $exps)
{
if ($exps->is_empty() || last($exps->expressions)->jumps()) {
return $exps;
}
return $exps->push(yy('Call', yy('Value', yy('Literal', $name), array(yy('Access', yy('Literal', 'push')))), array($exps->pop())));
}
开发者ID:TeigneuX,项目名称:php-websocket,代码行数:7,代码来源:push.php
示例18: mergePriority
protected function mergePriority($route)
{
$row = last($this->groupStack);
if (isset($row['priority'])) {
$route->setPriority($row['priority']);
}
}
开发者ID:sleeping-owl,项目名称:route-priority,代码行数:7,代码来源:Router.php
示例19: loadRestrictedNamespace
/**
* Load the namespace which prevents use of an Almanac name, if one exists.
*/
public static function loadRestrictedNamespace(PhabricatorUser $viewer, $name)
{
// For a name like "x.y.z", produce a list of controlling namespaces like
// ("z", "y.x", "x.y.z").
$names = array();
$parts = explode('.', $name);
for ($ii = 0; $ii < count($parts); $ii++) {
$names[] = implode('.', array_slice($parts, -($ii + 1)));
}
// Load all the possible controlling namespaces.
$namespaces = id(new AlmanacNamespaceQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withNames($names)->execute();
if (!$namespaces) {
return null;
}
// Find the "nearest" (longest) namespace that exists. If both
// "sub.domain.com" and "domain.com" exist, we only care about the policy
// on the former.
$namespaces = msort($namespaces, 'getNameLength');
$namespace = last($namespaces);
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $namespace, PhabricatorPolicyCapability::CAN_EDIT);
if ($can_edit) {
return null;
}
return $namespace;
}
开发者ID:Houzz,项目名称:phabricator,代码行数:28,代码来源:AlmanacNamespace.php
示例20: testLists
public function testLists()
{
$lists = Post::where('views', '>=', 10)->lists('id', 'title');
$debug = last(DB::getQueryLog());
$this->assertEquals(['Bar' => 2, 'FooBar' => 3], $lists);
$this->assertEquals('select "id", "title" from "posts" where "published" = ? and "views" >= ? and "status" = ?', $debug['query']);
}
开发者ID:pixelpeter,项目名称:eloquent-filterable,代码行数:7,代码来源:EloquentFilterTest.php
注:本文中的last函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论