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


PHP end函数代码示例

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


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

示例1: truncate

 /**
  * Truncates a string to the given length.  It will optionally preserve
  * HTML tags if $is_html is set to true.
  *
  * @param   string  $string        the string to truncate
  * @param   int     $limit         the number of characters to truncate too
  * @param   string  $continuation  the string to use to denote it was truncated
  * @param   bool    $is_html       whether the string has HTML
  * @return  string  the truncated string
  */
 public static function truncate($string, $limit, $continuation = '...', $is_html = false)
 {
     $offset = 0;
     $tags = array();
     if ($is_html) {
         // Handle special characters.
         preg_match_all('/&[a-z]+;/i', strip_tags($string), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] >= $limit) {
                 break;
             }
             $limit += static::length($match[0][0]) - 1;
         }
         // Handle all the html tags.
         preg_match_all('/<[^>]+>([^<]*)/', $string, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
         foreach ($matches as $match) {
             if ($match[0][1] - $offset >= $limit) {
                 break;
             }
             $tag = static::sub(strtok($match[0][0], " \t\n\r\v>"), 1);
             if ($tag[0] != '/') {
                 $tags[] = $tag;
             } elseif (end($tags) == static::sub($tag, 1)) {
                 array_pop($tags);
             }
             $offset += $match[1][1] - $match[0][1];
         }
     }
     $new_string = static::sub($string, 0, $limit = min(static::length($string), $limit + $offset));
     $new_string .= static::length($string) > $limit ? $continuation : '';
     $new_string .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
     return $new_string;
 }
开发者ID:huglester,项目名称:pyrocms-helpers,代码行数:43,代码来源:Str.php

示例2: addnew

 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
开发者ID:PHP-web-artisans,项目名称:ustora_backend,代码行数:34,代码来源:brands.php

示例3: registerScript

 /**
  * @param $name
  * @param array $params
  * @return string
  */
 public function registerScript($name, $params)
 {
     $out = '';
     if (!isset($this->modx->loadedjscripts[$name])) {
         $src = $params['src'];
         $remote = strpos($src, "http") !== false;
         if (!$remote) {
             $src = $this->modx->config['site_url'] . $src;
             if (!$this->fs->checkFile($params['src'])) {
                 $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper');
                 return false;
             }
         }
         $type = isset($params['type']) ? $params['type'] : end(explode('.', $src));
         if ($type == 'js') {
             $out = '<script type="text/javascript" src="' . $src . '"></script>';
         } else {
             $out = '<link rel="stylesheet" type="text/css" href="' . $src . '">';
         }
         $this->modx->loadedjscripts[$name] = $params;
     } else {
         $out = false;
     }
     return $out;
 }
开发者ID:AgelxNash,项目名称:modx.evo.custom,代码行数:30,代码来源:Assets.php

示例4: foo

function foo(&$state)
{
    $contentDict = end($state);
    for ($contentDict = end($state); $contentDict !== false; $contentDict = prev($state)) {
        echo key($state) . " => " . current($state) . "\n";
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bug35022.php

示例5: parse

 /**
  * load and parse given file.
  * 
  * @param string $name Name of file to load.
  * 
  * @return IAcitive Loaded activity.
  */
 public function parse($name)
 {
     $file_type = end(explode(".", $name));
     $class = '\\utils\\parser\\' . $file_type;
     $parser = new \utils\parser\context(new $class());
     return $parser->algorithm(DIR_UPLOAD . $name);
 }
开发者ID:uchwyt,项目名称:obtuse-broccoli,代码行数:14,代码来源:parseFile.php

示例6: iShouldSeeTheFollowingMetadata

 /**
  * @Then I should see the following metadata:
  */
 public function iShouldSeeTheFollowingMetadata(TableNode $metadata)
 {
     /** @var NodeElement $table */
     $table = $this->getSession()->getPage()->find('css', '#content > table');
     /** @var NodeElement $row */
     $row = $table->findAll('css', 'tr')[1];
     /** @var NodeElement[] $columns */
     $columns = $row->findAll('css', 'td');
     $contentIndex = $this->getColumnIndex($table, 'Content');
     /** @var NodeElement $list */
     $list = $columns[$contentIndex];
     foreach ($metadata->getRowsHash() as $key => $value) {
         $currentElement = $list;
         $parts = explode('.', $key);
         foreach ($parts as $part) {
             $currentElement = $currentElement->find('xpath', sprintf('/ul/li[starts-with(normalize-space(.), "%s:")]', $part));
         }
         $exploded = explode(':', $currentElement->getText());
         $text = trim(end($exploded));
         $expectedValue = $value;
         if ('<empty>' === $expectedValue) {
             $expectedValue = 'empty';
         } elseif (false !== strpos($expectedValue, ',')) {
             $expectedValue = str_replace([', ', ','], [' ', ' '], $expectedValue);
         }
         if ($text !== $expectedValue) {
             throw new \Exception(sprintf('Expected "%s", got "%s" (item: "%s", original value: "%s")', $expectedValue, $text, $key, $value));
         }
     }
 }
开发者ID:sidibea,项目名称:Sylius,代码行数:33,代码来源:MetadataContext.php

示例7: findGreatestBoundedValue

 /** Find the greatest key that is less than or equal to a given upper
  * bound, and return the value associated with that key.
  *
  * @param integer|null $maximumKey The upper bound for keys. If null, the
  *        maxiumum valued key will be found.
  * @param array $collection An two-dimensional array of key/value pairs
  *        to search through.
  * @returns mixed The value corresponding to the located key.
  * @throws \Zend\GData\App\Exception Thrown if $collection is empty.
  */
 public static function findGreatestBoundedValue($maximumKey, $collection)
 {
     $found = false;
     $foundKey = $maximumKey;
     // Sanity check: Make sure that the collection isn't empty
     if (sizeof($collection) == 0) {
         throw new Exception("Empty namespace collection encountered.");
     }
     if ($maximumKey === null) {
         // If the key is null, then we return the maximum available
         $keys = array_keys($collection);
         sort($keys);
         $found = true;
         $foundKey = end($keys);
     } else {
         // Otherwise, we optimistically guess that the current version
         // will have a matching namespce. If that fails, we decrement the
         // version until we find a match.
         while (!$found && $foundKey >= 0) {
             if (array_key_exists($foundKey, $collection)) {
                 $found = true;
             } else {
                 $foundKey--;
             }
         }
     }
     // Guard: A namespace wasn't found. Either none were registered, or
     // the current protcol version is lower than the maximum namespace.
     if (!$found) {
         throw new Exception("Namespace compatible with current protocol not found.");
     }
     return $foundKey;
 }
开发者ID:rexmac,项目名称:zf2,代码行数:43,代码来源:Util.php

示例8: actionLogin

 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $model = new LoginForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             if (end(explode("/", Yii::app()->user->returnUrl)) == 'index.php') {
                 $this->redirect('negociosavenda/');
             } else {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         } else {
             Yii::app()->user->setFlash('#usr_error', true);
             $this->redirect(array('/negociosavenda'));
         }
     }
     // display the login form
     //$this->render('/layouts/comuns/_loginForm',array('model'=>$model));
 }
开发者ID:renatocosta,项目名称:sunbeltbrasil,代码行数:29,代码来源:SiteController.php

示例9: getLast

 /**
  * Gets the last element of the array
  *
  * @throws StateException in case when empty
  * @return mixed
  */
 function getLast()
 {
     if (!sizeof($this->values)) {
         throw new StateException('empty array');
     }
     return end($this->values);
 }
开发者ID:phoebius,项目名称:phoebius,代码行数:13,代码来源:ValueArray.class.php

示例10: __construct

 public function __construct(array $lines)
 {
     $this->lines = array_values($lines);
     $keys = array_keys($lines);
     $this->start = $keys[0];
     $this->end = end($keys);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:7,代码来源:Annotation.php

示例11: _loadTerms

 /**
  * Load terms and try to sort it by names
  *
  * @return Mage_CatalogSearch_Block_Term
  */
 protected function _loadTerms()
 {
     if (empty($this->_terms)) {
         $this->_terms = array();
         $terms = Mage::getResourceModel('catalogsearch/query_collection')->setPopularQueryFilter(Mage::app()->getStore()->getId())->setPageSize(100)->load()->getItems();
         if (count($terms) == 0) {
             return $this;
         }
         $this->_maxPopularity = reset($terms)->getPopularity();
         $this->_minPopularity = end($terms)->getPopularity();
         $range = $this->_maxPopularity - $this->_minPopularity;
         $range = $range == 0 ? 1 : $range;
         foreach ($terms as $term) {
             if (!$term->getPopularity()) {
                 continue;
             }
             $term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range);
             $temp[$term->getName()] = $term;
             $termKeys[] = $term->getName();
         }
         natcasesort($termKeys);
         foreach ($termKeys as $termKey) {
             $this->_terms[$termKey] = $temp[$termKey];
         }
     }
     return $this;
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:32,代码来源:Term.php

示例12: execute

 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
开发者ID:bound1ess,项目名称:adviser,代码行数:40,代码来源:AnalyseRepositoryCommand.php

示例13: getInvoiceItems

 function getInvoiceItems($id)
 {
     $sql = "SELECT * FROM " . TB_PREFIX . "invoice_items WHERE invoice_id = :id";
     $sth = dbQuery($sql, ':id', $id);
     $invoiceItems = null;
     for ($i = 0; $invoiceItem = $sth->fetch(); $i++) {
         $invoiceItem['quantity'] = $invoiceItem['quantity'];
         $invoiceItem['unit_price'] = $invoiceItem['unit_price'];
         $invoiceItem['tax_amount'] = $invoiceItem['tax_amount'];
         $invoiceItem['gross_total'] = $invoiceItem['gross_total'];
         $invoiceItem['total'] = $invoiceItem['total'];
         $sql = "SELECT * FROM " . TB_PREFIX . "products WHERE id = :id";
         $tth = dbQuery($sql, ':id', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['product'] = $tth->fetch();
         $attr_sql = "select \r\n                    CONCAT(a.display_name, '-',v.value) as display,\r\n\t\t\t\t\tCONCAT(p.id, '-', a.id, '-', v.id) as id, \r\n\t\t\t\t\ta.id as aid \r\n                from\r\n                    si_products_attributes a,\r\n                    si_products_values v,\r\n\t\t\t\t\tsi_products_matrix m,\r\n\t\t\t\t\tsi_products p\r\n                where\r\n\t\t\t\t\tp.id = m.product_id \r\n\t\t\t\t\tand \r\n\t\t\t\t\ta.id = m.attribute_id \r\n\t\t\t\t\tand \r\n                    a.id = v.attribute_id\r\n\t\t\t\t\tand\r\n\t\t\t\t\tp.id = :pid\r\n                    and\r\n                    v.id = :attr_id";
         $attr_all_sql = "select \r\n                    CONCAT(a.display_name, '-',v.value) as display,\r\n\t\t\t\t\tCONCAT(p.id, '-', a.id, '-', v.id) as id \r\n\t\t\t\t\r\n                from\r\n                    si_products_attributes a,\r\n                    si_products_values v,\r\n\t\t\t\t\tsi_products_matrix m,\r\n\t\t\t\t\tsi_products p\r\n                where\r\n\t\t\t\t\tp.id = m.product_id \r\n\t\t\t\t\tand \r\n\t\t\t\t\ta.id = m.attribute_id \r\n\t\t\t\t\tand \r\n                    a.id = v.attribute_id\r\n\t\t\t\t\tand\r\n\t\t\t\t\tp.id = :pid\r\n                    and\r\n                    m.attribute_id = :aid\r\n                    and\r\n                    v.id != :attr_id";
         $attr1 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_1'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr1'] = $attr1->fetch();
         $attr_all_1 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_1'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr1']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_1'] = $attr_all_1->fetchAll();
         $attr2 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_2'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr2'] = $attr2->fetch();
         $attr_all_2 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_2'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr2']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_2'] = $attr_all_2->fetchAll();
         $attr3 = dbQuery($attr_sql, ':attr_id', $invoiceItem['attribute_3'], ':pid', $invoiceItem['product_id']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr3'] = $attr3->fetch();
         $attr_all_3 = dbQuery($attr_all_sql, ':attr_id', $invoiceItem['attribute_3'], ':pid', $invoiceItem['product_id'], ':aid', $invoiceItem['attr2']['aid']) or die(htmlsafe(end($dbh->errorInfo())));
         $invoiceItem['attr_all_3'] = $attr_all_3->fetchAll();
         $invoiceItems[$i] = $invoiceItem;
     }
     return $invoiceItems;
 }
开发者ID:alachaum,项目名称:simpleinvoices,代码行数:32,代码来源:sql_queries.php

示例14: main

function main($num)
{
    if ($num < 0) {
        $s = 1;
        $num = -$num;
    } else {
        $s = 0;
    }
    $zs = floor($num);
    $bzs = decbin($zs);
    $xs = $num - $zs;
    $res = (double) ($bzs . '.' . tenToBinary($xs, 1));
    $teme = ws($res);
    $e = decbin($teme + 127);
    if ($teme == 0) {
        $e = '0' . $e;
    }
    $temm = $res / pow(10, $teme);
    $m = end(explode(".", $temm));
    $lenm = strlen($m);
    if ($lenm < 23) {
        $m .= addzero(23 - $lenm);
    }
    return $s . ' ' . $e . ' ' . $m . ' ';
}
开发者ID:echosoar,项目名称:phpBinary,代码行数:25,代码来源:floatToIEEE32.php

示例15: addItem

 /**
  * Add an item of type BaseField to the field collection
  *
  * @param BaseField $objItem
  */
 public function addItem(BaseField $objItem)
 {
     $this->items[] = $objItem;
     end($this->items);
     $key = key($this->items);
     $this->index[$key] = $objItem->get('colName');
 }
开发者ID:hh-com,项目名称:contao-mm-frontendInput,代码行数:12,代码来源:FieldCollection.php


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