本文整理汇总了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
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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;
}
示例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();
}
}
示例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);
}
示例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));
}
}
}
示例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
);
}
示例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);
}
示例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.
}
}
示例13: get_hook
function get_hook($name)
{
global $plugins_hooks;
if (isset($plugins_hooks[$name])) {
return implode('', $plugins_hooks[$name]);
}
}
示例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);
}
示例15: get_token_from_guids
function get_token_from_guids($guids)
{
$guids = array_unique($guids);
sort($guids);
$string = implode(',', $guids);
return md5($string);
}