本文整理汇总了PHP中explode函数的典型用法代码示例。如果您正苦于以下问题:PHP explode函数的具体用法?PHP explode怎么用?PHP explode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了explode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: partial
public function partial($partial, $__time = false, $params = null, $group = 'kumbia.partials')
{
// if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
// return;
// }
//Verificando el partials en el dir app
$__file = $this->viewPath . "/_shared/partials/{$partial}.phtml";
// if (!is_file($__file)) {
// //Verificando el partials en el dir core
// $__file = CORE_PATH . "views/partials/$partial.phtml";
// }
if ($params) {
if (is_string($params)) {
$params = Util::getParams(explode(',', $params));
}
// carga los parametros en el scope
extract($params, EXTR_OVERWRITE);
}
// carga la vista parcial
if (!(include $__file)) {
throw new \Exception('Vista Parcial "' . $__file . '" no se encontro');
}
// se guarda en la cache de ser requerido
// if (PRODUCTION && $__time) {
// Cache::driver()->end();
// }
}
示例2: 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
}
示例3: ur_questions
/**
* @throws \PhpOffice\PhpWord\Exception\Exception
* Создание word для юр вопросов
*/
public static function ur_questions($row)
{
$user = User::findOne(\Yii::$app->user->identity->id);
$file = \Yii::$app->basePath . '/temp/ur_questions/' . $row['qid'] . '.docx';
$template = \Yii::$app->basePath . '/temp/ur_questions/Template.docx';
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template);
// Variables on different parts of document
$row['question'] = str_replace("\n", "<w:br/>", $row['question']);
//Для пробелов
$templateProcessor->setValue('vopros', $row['question']);
$templateProcessor->setValue('date', date("d.m.Y"));
$templateProcessor->setValue('ur_name', $row['uname']);
$templateProcessor->setValue('ur_ruk', $row['contact_face']);
$templateProcessor->setValue('ur_phone', $row['contact_phone']);
$templateProcessor->setValue('ur_mail', $row['contact_mail']);
$templateProcessor->setValue('ur_region', $row['rname']);
//$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
$templateProcessor->saveAs($file);
$qf = explode("|", $row['qfiles']);
if (!isset($qf[0])) {
$qf[0] = $qf;
}
$mail = \Yii::$app->mail->compose('ur_questions', ['uname' => $row['uname'], 'username' => $user['username'], 'mail' => $user['mail']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo(\Yii::$app->params['uristEmail'])->setSubject('Юридический вопрос')->attach($file);
foreach ($qf as $q) {
if ($q != "") {
$mail->attach($q);
}
}
$mail->send();
// if($templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx')) {
// return true;
// }else{
// return false;
// }
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure|\Closure $next
* @param $permissions
* @return mixed
* @internal param $roles
* @internal param null|string $guard
*/
public function handle(Request $request, Closure $next, $permissions)
{
if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
abort(403);
}
return $next($request);
}
示例5: onls
function onls()
{
$logdir = UC_ROOT . 'data/logs/';
$dir = opendir($logdir);
$logs = $loglist = array();
while ($entry = readdir($dir)) {
if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
$logs = array_merge($logs, file($logdir . $entry));
}
}
closedir($dir);
$logs = array_reverse($logs);
foreach ($logs as $k => $v) {
if (count($v = explode("\t", $v)) > 1) {
$v[3] = $this->date($v[3]);
$v[4] = $this->lang[$v[4]];
$loglist[$k] = $v;
}
}
$page = max(1, intval($_GET['page']));
$start = ($page - 1) * UC_PPP;
$num = count($loglist);
$multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
$loglist = array_slice($loglist, $start, UC_PPP);
$this->view->assign('loglist', $loglist);
$this->view->assign('multipage', $multipage);
$this->view->display('admin_log');
}
示例6: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$view = $this->entity;
$form['#prefix'] = '<div id="views-preview-wrapper" class="views-admin clearfix">';
$form['#suffix'] = '</div>';
$form['#id'] = 'views-ui-preview-form';
$form_state->disableCache();
$form['controls']['#attributes'] = array('class' => array('clearfix'));
$form['controls']['title'] = array('#prefix' => '<h2 class="view-preview-form__title">', '#markup' => $this->t('Preview'), '#suffix' => '</h2>');
// Add a checkbox controlling whether or not this display auto-previews.
$form['controls']['live_preview'] = array('#type' => 'checkbox', '#id' => 'edit-displays-live-preview', '#title' => $this->t('Auto preview'), '#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'));
// Add the arguments textfield
$form['controls']['view_args'] = array('#type' => 'textfield', '#title' => $this->t('Preview with contextual filters:'), '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), '#id' => 'preview-args');
$args = array();
if (!$form_state->isValueEmpty('view_args')) {
$args = explode('/', $form_state->getValue('view_args'));
}
$user_input = $form_state->getUserInput();
if ($form_state->get('show_preview') || !empty($user_input['js'])) {
$form['preview'] = array('#weight' => 110, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), 'preview' => $view->renderPreview($this->displayID, $args));
}
$uri = $view->urlInfo('preview-form');
$uri->setRouteParameter('display_id', $this->displayID);
$form['#action'] = $uri->toString();
return $form;
}
示例7: partialName
public function partialName($user_id)
{
$name = $this->findByAttributes(['user_id' => $user_id])->row_array();
$lastname = explode(' ', $name['family_name']);
$partialName = $name['given_name'] . ' ' . $lastname[count($lastname) - 1];
return $partialName;
}
示例8: fetchLinks
/**
* Fetch Links
*
* Fetches a set of links corresponding to an OpenURL
*
* @param string $openURL openURL (url-encoded)
*
* @return string raw XML returned by resolver
* @access public
*/
public function fetchLinks($openURL)
{
// Unfortunately the EZB-API only allows OpenURL V0.1 and
// breaks when sending a non expected parameter (like an ISBN).
// So we do have to 'downgrade' the OpenURL-String from V1.0 to V0.1
// and exclude all parameters that are not compliant with the EZB.
// Parse OpenURL into associative array:
$tmp = explode('&', $openURL);
$parsed = array();
foreach ($tmp as $current) {
$tmp2 = explode('=', $current, 2);
$parsed[$tmp2[0]] = $tmp2[1];
}
// Downgrade 1.0 to 0.1
if ($parsed['ctx_ver'] == 'Z39.88-2004') {
$openURL = $this->_downgradeOpenUrl($parsed);
}
// make the request IP-based to allow automatic
// indication on institution level
$openURL .= '&pid=client_ip%3D' . $_SERVER['REMOTE_ADDR'];
// Make the call to the EZB and load results
$url = $this->_baseUrl . '?' . $openURL;
$feed = file_get_contents($url);
return $feed;
}
示例9: 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');
}
示例10: beforeMethod
/**
* 'beforeMethod' event handles. This event handles intercepts GET requests ending
* with ?export
*
* @param string $method
* @param string $uri
* @return bool
*/
public function beforeMethod($method, $uri)
{
if ($method != 'GET') {
return;
}
if ($this->server->httpRequest->getQueryString() != 'export') {
return;
}
// splitting uri
list($uri) = explode('?', $uri, 2);
$node = $this->server->tree->getNodeForPath($uri);
if (!$node instanceof IAddressBook) {
return;
}
// Checking ACL, if available.
if ($aclPlugin = $this->server->getPlugin('acl')) {
$aclPlugin->checkPrivileges($uri, '{DAV:}read');
}
$this->server->httpResponse->setHeader('Content-Type', 'text/directory');
$this->server->httpResponse->sendStatus(200);
$nodes = $this->server->getPropertiesForPath($uri, array('{' . Plugin::NS_CARDDAV . '}address-data'), 1);
$this->server->httpResponse->sendBody($this->generateVCF($nodes));
// Returning false to break the event chain
return false;
}
示例11: 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;
}
示例12: openseadragon
/**
* Return a OpenSeadragon image viewer for the provided files.
*
* @param File|array $files A File record or an array of File records.
* @param int $width The width of the image viewer in pixels.
* @param int $height The height of the image viewer in pixels.
* @return string|null
*/
public function openseadragon($files)
{
if (!is_array($files)) {
$files = array($files);
}
// Filter out invalid images.
$images = array();
$imageNames = array();
foreach ($files as $file) {
// A valid image must be a File record.
if (!$file instanceof File) {
continue;
}
// A valid image must have a supported extension.
$extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
continue;
}
$images[] = $file;
$imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
}
// Return if there are no valid images.
if (!$images) {
return;
}
return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
}
示例13: get_exif
function get_exif($file)
{
if (!function_exists('exif_read_data')) {
return false;
}
$exif = @exif_read_data($file, "IFD0");
if ($exif === false) {
return false;
}
$exif_info = exif_read_data($file, NULL, true);
$exif_arr = $this->supported_exif();
$new_exif = array();
foreach ($exif_arr as $k => $v) {
$arr = explode('.', $v);
if (isset($exif_info[$arr[0]])) {
if (isset($exif_info[$arr[0]][$arr[1]])) {
$new_exif[$k] = $exif_info[$arr[0]][$arr[1]];
} else {
$new_exif[$k] = false;
}
} else {
$new_exif[$k] = false;
}
if ($k == 'Software' && !empty($new_exif['Software'])) {
$new_exif['Software'] = preg_replace('/([^a-zA-Z0-9_\\-,\\.\\:&#@!\\(\\)\\s]+)/i', '', $new_exif['Software']);
}
}
return $new_exif;
}
示例14: setUp
public function setUp(PDO $pdo, $sql)
{
$sql = explode(';', trim($sql));
foreach ($sql as $query) {
$pdo->exec(trim($query));
}
}
示例15: 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);
}