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


PHP implode函数代码示例

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


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

示例1: inet6_expand

/**
 * Expand an IPv6 Address
 *
 * This will take an IPv6 address written in short form and expand it to include all zeros. 
 *
 * @param  string  $addr A valid IPv6 address
 * @return string  The expanded notation IPv6 address
 */
function inet6_expand($addr)
{
    /* Check if there are segments missing, insert if necessary */
    if (strpos($addr, '::') !== false) {
        $part = explode('::', $addr);
        $part[0] = explode(':', $part[0]);
        $part[1] = explode(':', $part[1]);
        $missing = array();
        for ($i = 0; $i < 8 - (count($part[0]) + count($part[1])); $i++) {
            array_push($missing, '0000');
        }
        $missing = array_merge($part[0], $missing);
        $part = array_merge($missing, $part[1]);
    } else {
        $part = explode(":", $addr);
    }
    // if .. else
    /* Pad each segment until it has 4 digits */
    foreach ($part as &$p) {
        while (strlen($p) < 4) {
            $p = '0' . $p;
        }
    }
    // foreach
    unset($p);
    /* Join segments */
    $result = implode(':', $part);
    /* Quick check to make sure the length is as expected */
    if (strlen($result) == 39) {
        return $result;
    } else {
        return false;
    }
    // if .. else
}
开发者ID:samburney,项目名称:pdns-backend-phpautoreverse,代码行数:43,代码来源:ipv6_functions.php

示例2: qqwb_env

function qqwb_env()
{
    $msgs = array();
    $files = array(ROOT_PATH . 'include/ext/qqwb/qqoauth.php', ROOT_PATH . 'include/ext/qqwb/oauth.php', ROOT_PATH . 'modules/qqwb.mod.php');
    foreach ($files as $f) {
        if (!is_file($f)) {
            $msgs[] = "文件<b>{$f}</b>不存在";
        }
    }
    $funcs = array('version_compare', array('fsockopen', 'pfsockopen'), 'preg_replace', array('iconv', 'mb_convert_encoding'), array("hash_hmac", "mhash"));
    foreach ($funcs as $func) {
        if (!is_array($func)) {
            if (!function_exists($func)) {
                $msgs[] = "函数<b>{$func}</b>不可用";
            }
        } else {
            $t = false;
            foreach ($func as $f) {
                if (function_exists($f)) {
                    $t = true;
                    break;
                }
            }
            if (!$t) {
                $msgs[] = "函数<b>" . implode(" , ", $func) . "</b>都不可用";
            }
        }
    }
    return $msgs;
}
开发者ID:YouthAndra,项目名称:huaitaoo2o,代码行数:30,代码来源:qqwb_env.func.php

示例3: setValue

 /**
  * Sets selected items (by keys).
  * @param  array
  * @return self
  */
 public function setValue($values)
 {
     if (is_scalar($values) || $values === NULL) {
         $values = (array) $values;
     } elseif (!is_array($values)) {
         throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name));
     }
     $flip = [];
     foreach ($values as $value) {
         if (!is_scalar($value) && !method_exists($value, '__toString')) {
             throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name));
         }
         $flip[(string) $value] = TRUE;
     }
     $values = array_keys($flip);
     if ($this->checkAllowedValues && ($diff = array_diff($values, array_keys($this->items)))) {
         $set = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) {
             return var_export($s, TRUE);
         }, array_keys($this->items))), 70, '...');
         $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'";
         throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed set [{$set}] in field '{$this->name}'.");
     }
     $this->value = $values;
     return $this;
 }
开发者ID:jjanekk,项目名称:forms,代码行数:30,代码来源:MultiChoiceControl.php

示例4: generate_cookie

 public function generate_cookie()
 {
     $characters = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0';
     $characters_array = explode(',', $characters);
     shuffle($characters_array);
     return implode('', $characters_array);
 }
开发者ID:jhernani,项目名称:chu,代码行数:7,代码来源:E_security.php

示例5: display

 /**
  * Displays a view
  *
  * @param mixed What page to display
  * @return void
  * @throws NotFoundException When the view file could not be found
  *	or MissingViewException in debug mode.
  */
 public function display()
 {
     $path = func_get_args();
     //debug($path);
     $count = count($path);
     //debug($count);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = $title_for_layout = null;
     //debug(Inflector::humanize($path[$count - 1]));
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     if (!empty($path[$count - 1])) {
         $title_for_layout = Inflector::humanize($path[$count - 1]);
     }
     $this->set(compact('page', 'subpage', 'title_for_layout'));
     //debug($this->render(implode('/', $path)));
     //debug($page);
     //debug($subpage);
     //debug($title_for_layout);
     try {
         $this->render(implode('/', $path));
     } catch (MissingViewException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
 }
开发者ID:pavsnellski,项目名称:SMC,代码行数:42,代码来源:PagesController.php

示例6: addUserFacebook

 /**
  * Add facebook user
  */
 public function addUserFacebook($aVals, $iFacebookUserId, $sAccessToken)
 {
     if (!defined('PHPFOX_IS_FB_USER')) {
         define('PHPFOX_IS_FB_USER', true);
     }
     //get facebook setting
     $bFbConnect = Phpfox::getParam('facebook.enable_facebook_connect');
     if ($bFbConnect == false) {
         return false;
     } else {
         if (Phpfox::getService('accountapi.facebook')->checkUserFacebook($iFacebookUserId) == false) {
             if (Phpfox::getParam('user.disable_username_on_sign_up')) {
                 $aVals['user_name'] = Phpfox::getLib('parse.input')->cleanTitle($aVals['full_name']);
             }
             $aVals['country_iso'] = null;
             if (Phpfox::getParam('user.split_full_name')) {
                 $aNameSplit = preg_split('[ ]', $aVals['full_name']);
                 $aVals['first_name'] = $aNameSplit[0];
                 unset($aNameSplit[0]);
                 $aVals['last_name'] = implode(' ', $aNameSplit);
             }
             $iUserId = Phpfox::getService('user.process')->add($aVals);
             if ($iUserId === false) {
                 return false;
             } else {
                 Phpfox::getService('facebook.process')->addUser($iUserId, $iFacebookUserId);
                 //update fb profile image to db
                 $bCheck = Phpfox::getService('accountapi.facebook')->addImagePicture($sAccessToken, $iUserId);
             }
         }
     }
     return true;
 }
开发者ID:PhpFoxPro,项目名称:Better-Mobile-Module,代码行数:36,代码来源:facebook.class.php

示例7: edit

 public function edit()
 {
     if (IS_POST) {
         $post_data = I('post.');
         $post_data["rules"] = I("post.rules");
         $post_data["rules"] = implode(",", $post_data["rules"]);
         $data = $this->Model->create($post_data);
         if ($data) {
             $result = $this->Model->where(array('id' => $post_data['id']))->save($data);
             if ($result) {
                 action_log('Edit_AuthGroup', 'AuthGroup', $post_data['id']);
                 $this->success("操作成功!", U('index'));
             } else {
                 $error = $this->Model->getError();
                 $this->error($error ? $error : "操作失败!");
             }
         } else {
             $error = $this->Model->getError();
             $this->error($error ? $error : "操作失败!");
         }
     } else {
         $_info = I('get.');
         $_info = $this->Model->where(array('id' => $_info['id']))->find();
         $this->assign('_info', $_info);
         $this->display();
     }
 }
开发者ID:hacklx,项目名称:koala-frame,代码行数:27,代码来源:AuthGroupController.class.php

示例8: match

 /**
  *
  * @see XenForo_Route_PrefixAdmin_AddOns::match()
  */
 public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
 {
     $parts = explode('/', $routePath, 3);
     switch ($parts[0]) {
         case 'languages':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
             return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
         case 'phrases':
             $parts = array_slice($parts, 1);
             $routePath = implode('/', $parts);
             return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
     }
     if (count($parts) > 1) {
         switch ($parts[1]) {
             case 'languages':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 $action = $router->resolveActionWithIntegerParam($routePath, $request, 'language_id');
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Language', $action, 'languages');
             case 'phrases':
                 $action = $router->resolveActionWithStringParam($routePath, $request, 'addon_id');
                 $parts = array_slice($parts, 2);
                 $routePath = implode('/', $parts);
                 return $router->getRouteMatch('XenForo_ControllerAdmin_Phrase', $routePath, 'phrases');
         }
     }
     return parent::match($routePath, $request, $router);
 }
开发者ID:ThemeHouse-XF,项目名称:Phrases,代码行数:35,代码来源:AddOns.php

示例9: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
     }
     $messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
     if ($ids) {
         $ids = array_fuse($ids);
         $missing = array_diff_key($ids, $messages);
         if ($missing) {
             throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
         }
     }
     $last_key = last_key($messages);
     foreach ($messages as $message_key => $message) {
         $info = array();
         $info[] = pht('PROPERTIES');
         $info[] = pht('ID: %d', $message->getID());
         $info[] = pht('Status: %s', $message->getSendStatus());
         $info[] = pht('To: %s', $message->getToNumber());
         $info[] = pht('From: %s', $message->getFromNumber());
         $info[] = null;
         $info[] = pht('BODY');
         $info[] = $message->getBody();
         $info[] = null;
         $console->writeOut('%s', implode("\n", $info));
         if ($message_key != $last_key) {
             $console->writeOut("\n%s\n\n", str_repeat('-', 80));
         }
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorSMSManagementShowOutboundWorkflow.php

示例10: configure

    public function configure()
    {
        $this->setName('phpcr:migrations:migrate');
        $this->addArgument('to', InputArgument::OPTIONAL, sprintf('Version name to migrate to, or an action: "<comment>%s</comment>"', implode('</comment>", "<comment>', $this->actions)));
        $this->setDescription('Migrate the content repository between versions');
        $this->setHelp(<<<EOT
Migrate to a specific version or perform an action.

By default it will migrate to the latest version:

    \$ %command.full_name%

You can migrate to a specific version (either in the "past" or "future"):

    \$ %command.full_name% 201504011200

Or specify an action

    \$ %command.full_name% <action>

Action can be one of:

- <comment>up</comment>: Migrate one version up
- <comment>down</comment>: Migrate one version down
- <comment>top</comment>: Migrate to the latest version
- <comment>bottom</comment>: Revert all migrations

EOT
);
    }
开发者ID:valiton-forks,项目名称:phpcr-migrations-bundle,代码行数:30,代码来源:MigrateCommand.php

示例11: convertDateMomentToPhp

 public static function convertDateMomentToPhp($format)
 {
     $tokens = ["M" => "n", "Mo" => "nS", "MM" => "m", "MMM" => "M", "MMMM" => "F", "D" => "j", "Do" => "jS", "DD" => "d", "DDD" => "z", "DDDo" => "zS", "DDDD" => "zS", "d" => "w", "do" => "wS", "dd" => "D", "ddd" => "D", "dddd" => "l", "e" => "w", "E" => "N", "w" => "W", "wo" => "WS", "ww" => "W", "W" => "W", "Wo" => "WS", "WW" => "W", "YY" => "y", "YYYY" => "Y", "gg" => "o", "gggg" => "o", "GG" => "o", "GGGG" => "o", "A" => "A", "a" => "a", "H" => "G", "HH" => "H", "h" => "g", "hh" => "h", "m" => "i", "mm" => "i", "s" => "s", "ss" => "s", "S" => "", "SS" => "", "SSS" => "", "z or zz" => "T", "Z" => "P", "ZZ" => "O", "X" => "U", "LT" => "g:i A", "L" => "m/d/Y", "l" => "n/j/Y", "LL" => "F jS Y", "ll" => "M j Y", "LLL" => "F js Y g:i A", "lll" => "M j Y g:i A", "LLLL" => "l, F jS Y g:i A", "llll" => "D, M j Y g:i A"];
     // find all tokens from string, using regular expression
     $regExp = "/(\\[[^\\[]*\\])|(\\\\)?(LT|LL?L?L?|l{1,4}|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/";
     $matches = array();
     preg_match_all($regExp, $format, $matches);
     //  if there is no match found then return the string as it is
     //  TODO: might return escaped string
     if (empty($matches) || is_array($matches) === false) {
         return $format;
     }
     //  to match with extracted tokens
     $momentTokens = array_keys($tokens);
     $phpMatches = array();
     //  ----------------------------------
     foreach ($matches[0] as $id => $match) {
         // if there is a matching php token in token list
         if (in_array($match, $momentTokens)) {
             // use the php token instead
             $string = $tokens[$match];
         } else {
             $string = $match;
         }
         $phpMatches[$id] = $string;
     }
     // join and return php specific tokens
     return implode("", $phpMatches);
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:29,代码来源:FormatConverter.php

示例12: assignfeedback_editpdf_pluginfile

/**
 * Serves assignment feedback and other files.
 *
 * @param mixed $course course or id of the course
 * @param mixed $cm course module or id of the course module
 * @param context $context
 * @param string $filearea
 * @param array $args
 * @param bool $forcedownload
 * @return bool false if file not found, does not return if found - just send the file
 */
function assignfeedback_editpdf_pluginfile($course, $cm, context $context, $filearea, $args, $forcedownload)
{
    global $USER, $DB, $CFG;
    if ($context->contextlevel == CONTEXT_MODULE) {
        require_login($course, false, $cm);
        $itemid = (int) array_shift($args);
        if (!($assign = $DB->get_record('assign', array('id' => $cm->instance)))) {
            return false;
        }
        $record = $DB->get_record('assign_grades', array('id' => $itemid), 'userid,assignment', MUST_EXIST);
        $userid = $record->userid;
        if ($assign->id != $record->assignment) {
            return false;
        }
        // Check is users feedback or has grading permission.
        if ($USER->id != $userid and !has_capability('mod/assign:grade', $context)) {
            return false;
        }
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/assignfeedback_editpdf/{$filearea}/{$itemid}/{$relativepath}";
        $fs = get_file_storage();
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Download MUST be forced - security!
        send_stored_file($file, 0, 0, true);
        // Check if we want to retrieve the stamps.
    }
}
开发者ID:pzhu2004,项目名称:moodle,代码行数:40,代码来源:lib.php

示例13: get_hook

function get_hook($name)
{
    global $plugins_hooks;
    if (isset($plugins_hooks[$name])) {
        return implode('', $plugins_hooks[$name]);
    }
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:7,代码来源:plugins.php

示例14: getPath

 public function getPath($categoryId, $accountId, $delimiter = ' > ')
 {
     $account = Mage::helper('M2ePro/Component_Ebay')->getCachedObject('Account', $accountId);
     $categories = $account->getChildObject()->getEbayStoreCategories();
     $pathData = array();
     while (true) {
         $currentCategory = NULL;
         foreach ($categories as $category) {
             if ($category['category_id'] == $categoryId) {
                 $currentCategory = $category;
                 break;
             }
         }
         if (is_null($currentCategory)) {
             break;
         }
         $pathData[] = $currentCategory['title'];
         if ($currentCategory['parent_id'] == 0) {
             break;
         }
         $categoryId = $currentCategory['parent_id'];
     }
     array_reverse($pathData);
     return implode($delimiter, $pathData);
 }
开发者ID:giuseppemorelli,项目名称:magento-extension,代码行数:25,代码来源:Store.php

示例15: get_token_from_guids

function get_token_from_guids($guids)
{
    $guids = array_unique($guids);
    sort($guids);
    $string = implode(',', $guids);
    return md5($string);
}
开发者ID:beck24,项目名称:granular_access,代码行数:7,代码来源:functions.php


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