• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP str_replace函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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;
     // }
 }
开发者ID:pumi11,项目名称:aau,代码行数:39,代码来源:Word.php


示例2: getLocation

function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
开发者ID:surevision,项目名称:node_mpg123_pi,代码行数:27,代码来源:xmu.php


示例3: collectData

 public function collectData(array $param)
 {
     $html = $this->file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
     $count = 0;
     $latest = 1;
     $latest_title = "";
     $latest = $html->find('div.conteneur_page a', 1)->href;
     $latest_title = $html->find('div.conteneur_page img', 0)->title;
     function MalikiExtractContent($url)
     {
         $html2 = $this->file_get_html($url);
         $text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
         $text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
         return $text;
     }
     $item = new \Item();
     $item->uri = 'http://www.maliki.com/' . $latest;
     $item->title = $latest_title;
     $item->timestamp = time();
     $item->content = MalikiExtractContent($item->uri);
     $this->items[] = $item;
     foreach ($html->find('div.boite_strip') as $element) {
         if (!empty($element->find('a', 0)->href) and $count < 3) {
             $item = new \Item();
             $item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
             $item->title = $element->find('img', 0)->title;
             $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
             $item->content = MalikiExtractContent($item->uri);
             $this->items[] = $item;
             $count++;
         }
     }
 }
开发者ID:ORelio,项目名称:rss-bridge,代码行数:33,代码来源:MalikiBridge.php


示例4: addFieldToModule

 public function addFieldToModule($field)
 {
     global $log;
     $fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php';
     $fileExists = file_exists($fileName);
     if ($fileExists) {
         require_once $fileName;
         $fileContent = file_get_contents($fileName);
         $placeToAdd = "'website' => 'text',";
         $newField = "'{$field}' => 'text',";
         if (self::parse_data($placeToAdd, $fileContent)) {
             $fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . '	' . $newField, $fileContent);
         } else {
             if (self::parse_data('?>', $fileContent)) {
                 $fileContent = str_replace('?>', '', $fileContent);
             }
             $fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . '	' . $newField . PHP_EOL . ');';
         }
         $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php ');
     } else {
         $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist');
         return FALSE;
     }
     $filePointer = fopen($fileName, 'w');
     fwrite($filePointer, $fileContent);
     fclose($filePointer);
     return TRUE;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:28,代码来源:SaveCompanyField.php


示例5: getEntityAlias

 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
开发者ID:antrampa,项目名称:platform,代码行数:36,代码来源:ExtendEntityAliasProvider.php


示例6: apiUpdateOrder

 public static function apiUpdateOrder($order, $response)
 {
     if (!defined('ORDER_MANAGEMENT')) {
         define('ORDER_MANAGEMENT', true);
     }
     if (!empty($order['status'])) {
         $statuses = fn_get_statuses(STATUSES_ORDER, false, true);
         if (!isset($statuses[$order['status']])) {
             $response->addError('ERROR_OBJECT_UPDATE', str_replace('[object]', 'orders', __('twgadmin_wrong_api_object_data')));
         } else {
             fn_change_order_status($order['order_id'], $order['status']);
         }
     }
     $cart = array();
     fn_clear_cart($cart, true);
     $customer_auth = fn_fill_auth(array(), array(), false, 'C');
     fn_form_cart($order['order_id'], $cart, $customer_auth);
     $cart['order_id'] = $order['order_id'];
     // update only profile data
     $profile_data = fn_check_table_fields($order, 'user_profiles');
     $cart['user_data'] = fn_array_merge($cart['user_data'], $profile_data);
     $cart['user_data'] = fn_array_merge($cart['user_data'], $order);
     fn_calculate_cart_content($cart, $customer_auth, 'A', true, 'I');
     if (!empty($order['details'])) {
         db_query('UPDATE ?:orders SET details = ?s WHERE order_id = ?i', $order['details'], $order['order_id']);
     }
     if (!empty($order['notes'])) {
         $cart['notes'] = $order['notes'];
     }
     fn_update_payment_surcharge($cart, $customer_auth);
     list($order_id, $process_payment) = fn_place_order($cart, $customer_auth, 'save');
     return array($order_id, $process_payment);
 }
开发者ID:askzap,项目名称:ultimate,代码行数:33,代码来源:TwigmoOrder.php


示例7: getAliases

 /**
  * Requests API data and returns aliases
  *
  * @return string
  */
 private function getAliases()
 {
     $request = new Request();
     $user = new User();
     $path = 'drush_aliases';
     $method = 'GET';
     $response = $request->request('users', Session::getValue('user_id'), $path, $method);
     eval(str_replace('<?php', '', $response['data']->drush_aliases));
     $formatted_aliases = substr($response['data']->drush_aliases, 0, -1);
     $sites_object = new Sites();
     $sites = $sites_object->all();
     foreach ($sites as $site) {
         $environments = $site->environments->all();
         foreach ($environments as $environment) {
             $key = $site->get('name') . '.' . $environment->get('id');
             if (isset($aliases[$key])) {
                 break;
             }
             try {
                 $formatted_aliases .= PHP_EOL . "  \$aliases['{$key}'] = ";
                 $formatted_aliases .= $this->constructAlias($environment);
             } catch (TerminusException $e) {
                 continue;
             }
         }
     }
     $formatted_aliases .= PHP_EOL;
     return $formatted_aliases;
 }
开发者ID:pantheon-systems,项目名称:terminus,代码行数:34,代码来源:PantheonAliases.php


示例8: getLinkDefsInFieldMeta

 /**
  * Get link definition defined in 'fields' metadata. In linkDefs can be used as value (e.g. "type": "hasChildren") and/or variables (e.g. "entityName":"{entity}"). Variables should be defined into fieldDefs (in 'entityDefs' metadata).
  *
  * @param  string $entityName
  * @param  array  $fieldDef
  * @param  array  $linkFieldDefsByType
  * @return array | null
  */
 public function getLinkDefsInFieldMeta($entityName, $fieldDef, array $linkFieldDefsByType = null)
 {
     if (!isset($fieldDefsByType)) {
         $fieldDefsByType = $this->getFieldDefsByType($fieldDef);
         if (!isset($fieldDefsByType['linkDefs'])) {
             return null;
         }
         $linkFieldDefsByType = $fieldDefsByType['linkDefs'];
     }
     foreach ($linkFieldDefsByType as $paramName => &$paramValue) {
         if (preg_match('/{(.*?)}/', $paramValue, $matches)) {
             if (in_array($matches[1], array_keys($fieldDef))) {
                 $value = $fieldDef[$matches[1]];
             } else {
                 if (strtolower($matches[1]) == 'entity') {
                     $value = $entityName;
                 }
             }
             if (isset($value)) {
                 $paramValue = str_replace('{' . $matches[1] . '}', $value, $paramValue);
             }
         }
     }
     return $linkFieldDefsByType;
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:33,代码来源:Helper.php


示例9: mdl_const

 function mdl_const($str_type)
 {
     if (!fn_token("chk")) {
         //令牌
         $this->obj_ajax->halt_alert("x030102");
     }
     $_arr_opt = fn_post("opt");
     $_str_content = "<?php" . PHP_EOL;
     foreach ($_arr_opt as $_key => $_value) {
         $_arr_optChk = validateStr($_value, 1, 900);
         $_str_optValue = $_arr_optChk["str"];
         if (is_numeric($_value)) {
             $_str_content .= "define(\"" . $_key . "\", " . $_str_optValue . ");" . PHP_EOL;
         } else {
             $_str_content .= "define(\"" . $_key . "\", \"" . str_replace(PHP_EOL, "|", $_str_optValue) . "\");" . PHP_EOL;
         }
     }
     if ($str_type == "base") {
         $_str_content .= "define(\"BG_SITE_SSIN\", \"" . fn_rand(6) . "\");" . PHP_EOL;
     } else {
         if ($str_type == "visit") {
             if ($_arr_opt["BG_VISIT_TYPE"] != "static") {
                 $_str_content .= "define(\"BG_VISIT_FILE\", \"html\");" . PHP_EOL;
             }
         }
     }
     $_str_content = str_replace("||", "", $_str_content);
     $_num_size = file_put_contents(BG_PATH_CONFIG . "opt_" . $str_type . ".inc.php", $_str_content);
     if ($_num_size > 0) {
         $_str_alert = "y060101";
     } else {
         $_str_alert = "x060101";
     }
     return array("alert" => $_str_alert);
 }
开发者ID:richardcj,项目名称:baigoCMS,代码行数:35,代码来源:opt.class.php


示例10: valida_valor

function valida_valor($valor, $aceita_float)
{
    // valida valor
    if ($valor == null) {
        // informa que nao e um valor
        return false;
    }
    // remove a virgula se houver
    $valor = str_replace(",", ".", $valor);
    // remove espaco vazio no meio se houver
    $valor = str_replace(" ", null, $valor);
    // remove o espaco em branco
    $valor = trim($valor);
    // valida se e numero, e se e numero positivo
    if (is_numeric($valor) == false or $valor < 0) {
        // informa que nao e um numero
        return false;
    }
    // arredonda valor se nao aceitar float
    if ($aceita_float == false) {
        // arredonda
        $valor = round($valor, 0);
    }
    // se aceitar float, e for float entao arredonda
    if ($aceita_float == true) {
        // arredonda
        $valor = round($valor, 2);
    }
    // retorno
    return $valor;
}
开发者ID:mvnp,项目名称:Comprapop,代码行数:31,代码来源:valida_valor.php


示例11: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $contents = $this->getKeyFile();
     $dbName = $this->argument('database');
     $dbUserName = $this->ask('What is your MySQL username?');
     $dbPassword = $this->secret('What is your MySQL password?');
     // Replace DB credentials taken from env.php file
     $keys = ['MYSQL_DATABASE', 'MYSQL_USERNAME', 'MYSQL_PASSWORD'];
     $search = ["'{$keys['0']}' => ''", "'{$keys['1']}' => ''", "'{$keys['2']}' => ''"];
     $replace = ["'{$keys['0']}' => '{$dbName}'", "'{$keys['1']}' => '{$dbUserName}'", "'{$keys['2']}' => '{$dbPassword}'"];
     $contents = str_replace($search, $replace, $contents, $count);
     if ($count != 3) {
         throw new Exception('Error while writing credentials to .env.php.');
     }
     // Set DB credentials to laravel config
     $this->laravel['config']['database.connections.mysql.database'] = $dbName;
     $this->laravel['config']['database.connections.mysql.username'] = $dbUserName;
     $this->laravel['config']['database.connections.mysql.password'] = $dbPassword;
     $this->error($this->laravel['config']['local.database.connections.mysql.database']);
     // Migrate DB
     if (!Schema::hasTable('migrations')) {
         $this->call('migrate');
         $this->call('db:seed');
     } else {
         $this->error('A migrations table was found in database [' . $dbName . '], no migrate and seed were done.');
     }
     // Write to .env.php
     $env = $this->laravel->environment();
     $newPath = $env == 'production' ? '.env.php' : '.env.' . $env . '.php';
     $this->files->put($newPath, $contents);
 }
开发者ID:mrkodssldrf,项目名称:TypiCMS,代码行数:36,代码来源:Database.php


示例12: throwError

 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     /**
      * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
      * because PHP has problems with including files that contain BOM character.
      * Having BOM character after <script> tag causes a javascript error.
      */
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKEditor'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
         echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         if (!$uploaded) {
             echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
         } else {
             echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
         }
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
开发者ID:knieper,项目名称:crltmich,代码行数:42,代码来源:QuickUpload.php


示例13: xml_debutElement

function xml_debutElement($phraseur, $name, $attrs)
{
    $depth = $phraseur->depth;
    $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
    // espace initial signifie: deja integree au resultat
    if ($t[0] != ' ') {
        $phraseur->res .= '<' . $t . '>';
        $phraseur->ouvrant[$depth] = ' ' . $t;
    }
    $t = $phraseur->contenu[$depth];
    // n'indenter que s'il y a un separateur avant
    $phraseur->res .= preg_replace("/[\n\t ]+\$/", "\n{$depth}", $t);
    $phraseur->contenu[$depth] = "";
    $att = '';
    $sep = ' ';
    foreach ($attrs as $k => $v) {
        $delim = strpos($v, "'") === false ? "'" : '"';
        $val = xml_entites_html($v);
        $att .= $sep . $k . "=" . $delim . ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val) . $delim;
        $sep = "\n {$depth}";
    }
    $phraseur->depth .= '  ';
    $phraseur->contenu[$phraseur->depth] = "";
    $phraseur->ouvrant[$phraseur->depth] = $name . $att;
    $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
}
开发者ID:nursit,项目名称:SPIP,代码行数:26,代码来源:sax.php


示例14: getUser

 /**
  * getUser
  *
  * read User by ID
  * id, int: id (required)
  * 
  * @return User
  */
 public function getUser($id)
 {
     // parse inputs
     $resourcePath = "/user_get_two_read1";
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     $method = "GET";
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $headerParams['Accept'] = '*/*';
     $headerParams['Content-Type'] = 'application/json';
     // query params
     if ($id !== null) {
         $queryParams['id'] = $this->apiClient->toQueryValue($id);
     }
     $body = $body ?: $formParams;
     if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
         $body = http_build_query($body);
     }
     // make the API Call
     $response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $body, $headerParams);
     if (!$response) {
         return null;
     }
     $responseObject = $this->apiClient->deserialize($response, 'User');
     return $responseObject;
 }
开发者ID:singlekingle,项目名称:swagger-spring-demo,代码行数:35,代码来源:UsergettworeadApi.php


示例15: underscore

 private function underscore($name)
 {
     $name = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1_\\2', $name);
     $name = preg_replace('/([a-z\\d])([A-Z])/', '\\1_\\2', $name);
     $name = str_replace(array('/', '\\'), array('.', '.'), $name);
     return $name;
 }
开发者ID:pfz,项目名称:codeception,代码行数:7,代码来源:GenerateScenarios.php


示例16: includePeer

 function includePeer($path = "general")
 {
     $_path = _FM_HOME_DIR . DS . 'symbiosis' . DS . _FM_PEER . DS . str_replace('.', DS, $path) . '.php';
     if (file_exists($_path)) {
         require_once $_path;
     }
 }
开发者ID:utopszkij,项目名称:lmp,代码行数:7,代码来源:bootstrap.php


示例17: filtre_picture

/**
 * On modifie les URLS des images dans le corps de l'article
 */
function filtre_picture($content, $url, $id)
{
    $matches = array();
    $processing_pictures = array();
    // list of processing image to avoid processing the same pictures twice
    preg_match_all('#<\\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
    foreach ($matches as $i => $link) {
        $link[1] = trim($link[1]);
        if (!preg_match('#^(([a-z]+://)|(\\#))#', $link[1])) {
            $absolute_path = get_absolute_link($link[2], $url);
            $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
            $directory = create_assets_directory($id);
            $fullpath = $directory . '/' . $filename;
            if (in_array($absolute_path, $processing_pictures) === true) {
                // replace picture's URL only if processing is OK : already processing -> go to next picture
                continue;
            }
            if (download_pictures($absolute_path, $fullpath) === true) {
                $content = str_replace($matches[$i][2], $fullpath, $content);
            }
            $processing_pictures[] = $absolute_path;
        }
    }
    return $content;
}
开发者ID:akoenig,项目名称:wallabag,代码行数:28,代码来源:pochePictures.php


示例18: ote_accent

function ote_accent($str)
{
    $str = str_replace("'", " ", $str);
    $str = utf8_decode($str);
    $ch = strtr($str, '����������������������������������������������������', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
    return utf8_encode($ch);
}
开发者ID:rtajmahal,项目名称:PrestaShop-modules,代码行数:7,代码来源:page_iso.php


示例19: doExecute

 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   1.0
  */
 public function doExecute()
 {
     jimport('joomla.filesystem.file');
     if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) {
         $configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php';
         if (is_writable($configfile)) {
             $config = file_get_contents($configfile);
             //Do a simple replace for the CMS and old school applications
             $newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config);
             // Newer applications generally use JSON instead.
             if (!$newconfig) {
                 $newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config);
             }
             if (!$newconfig) {
                 $this->out('This application does not have an offline configuration setting.');
             } else {
                 JFile::Write($configfile, &$newconfig);
                 $this->out('Site is offline');
             }
         } else {
             $this->out('The file is not writable, you need to change the file permissions first.');
             $this->out();
         }
     } else {
         $this->out('This application does not have a configuration file');
     }
     $this->out();
 }
开发者ID:joomlla,项目名称:jacs,代码行数:35,代码来源:TakeOffline.php


示例20: getApertureFields

 /**
  * Load metadata about an HTML document using Aperture.
  *
  * @param string $htmlFile File on disk containing HTML.
  *
  * @return array
  */
 protected static function getApertureFields($htmlFile)
 {
     $xmlFile = tempnam('/tmp', 'apt');
     $cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
     exec($cmd);
     // If we failed to process the file, give up now:
     if (!file_exists($xmlFile)) {
         throw new \Exception('Aperture failed.');
     }
     // Extract and decode the full text from the XML:
     $xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
     @unlink($xmlFile);
     preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
     $final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the title from the XML:
     preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
     $title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the keywords from the XML:
     preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
     $keywords = [];
     if (isset($matches[1])) {
         foreach ($matches[1] as $current) {
             $keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
         }
     }
     // Extract the description from the XML:
     preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
     $description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Send back the extracted fields:
     return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
 }
开发者ID:grharry,项目名称:vufind,代码行数:38,代码来源:VuFindSitemap.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP str_replace_array函数代码示例发布时间:2022-05-23
下一篇:
PHP str_repeat函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap