本文整理汇总了PHP中str_Replace函数的典型用法代码示例。如果您正苦于以下问题:PHP str_Replace函数的具体用法?PHP str_Replace怎么用?PHP str_Replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_Replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateOptions
function generateOptions(&$xml)
{
$template = (string) $this->_xml;
$cssfile = NextendFilesystem::translateToMediaPath(str_replace(DIRECTORY_SEPARATOR, '/', dirname($this->_form->_xmlfile)) . '/style.');
$css = NextendCss::getInstance();
if (NextendFilesystem::fileexists($cssfile . 'less')) {
$css->enableLess();
$cssfile .= 'less';
$css->addCssFile(array($cssfile, $cssfile, array('id' => 'body')));
} else {
$cssfile .= 'css';
$css->addCssFile($cssfile);
}
$prefix = NextendXmlGetAttribute($this->_xml, 'prefix');
$this->_values = array();
$html = '';
foreach ($xml->option as $option) {
$v = NextendXmlGetAttribute($option, 'value');
$this->_values[] = $v;
if ($v != -1) {
$info = pathinfo($v);
$class = $prefix . basename($v, '.' . $info['extension']);
$html .= '
<div class="nextend-radio-option nextend-imagelist-option' . $this->isSelected($v) . '">
' . str_Replace('{image}', NextendUri::pathToUri($v), str_Replace('{class}', $class, $template)) . '
</div>';
} else {
$html .= '<div class="nextend-radio-option' . $this->isSelected($v) . '">' . (string) $option . '</div>';
}
}
return $html;
}
示例2: parse
/**
* Parse the given file for apprentices and mentors.
*
* @param string $file Path to the File to parse.
*
* @return array
*/
public function parse($file)
{
$return = array('mentors' => array(), 'apprentices' => array());
$content = file_Get_contents($file);
$content = str_Replace('<local-time', '<span tag="local-time"', $content);
$content = str_Replace('</local-time', '</span', $content);
$content = str_Replace('<time', '<span tag="time"', $content);
$content = str_Replace('</time', '</span', $content);
$this->dom = new \DomDocument('1.0', 'UTF-8');
$this->dom->strictErrorChecking = false;
libxml_use_internal_errors(true);
$this->dom->loadHTML('<?xml encoding="UTF-8" ?>' . $content);
libxml_use_internal_errors(false);
$xpathMentors = new \DOMXPath($this->dom);
$mentors = $xpathMentors->query('//a[@id="user-content-mentors-currently-accepting-an-apprentice"]/../following-sibling::ul[1]/li');
foreach ($mentors as $mentor) {
$user = $this->parseUser($mentor);
if (!$user) {
continue;
}
$user['type'] = 'mentor';
$return['mentors'][] = $user;
}
$xpathApprentices = new \DOMXPath($this->dom);
$apprentices = $xpathApprentices->query('//a[@id="user-content-apprentices-currently-accepting-mentors"]/../following-sibling::ul[1]/li');
foreach ($apprentices as $apprentice) {
$user = $this->parseUser($apprentice);
if (!$user) {
continue;
}
$user['type'] = 'apprentice';
$return['apprentices'][] = $user;
}
return $return;
}
示例3: send_im
function send_im($user, $recipient, $message, $opt, &$errors)
{
global $config, $lang_set;
$sip_msg = "MESSAGE\n" . addslashes($recipient) . "\n" . ".\n" . "From: " . $user->get_uri() . "\n" . "To: <" . addslashes($recipient) . ">\n" . "p-version: " . $config->psignature . "\n" . "Contact: <" . $config->web_contact . ">\n" . "Content-Type: text/plain; charset=" . $lang_set['charset'] . "\n.\n" . str_Replace("\n.\n", "\n. \n", $message) . "\n.\n\n";
if ($config->use_rpc) {
if (!$this->connect_to_xml_rpc(null, $errors)) {
return false;
}
$params = array(new XML_RPC_Value($sip_msg, 'string'));
$msg = new XML_RPC_Message('t_uac_dlg', $params);
$res = $this->rpc->send($msg);
if ($this->rpc_is_error($res)) {
log_errors($res, $errors);
return false;
}
} else {
/* construct FIFO command */
$fifo_cmd = ":t_uac_dlg:" . $config->reply_fifo_filename . "\n" . $sip_msg;
if (false === write2fifo($fifo_cmd, $errors, $status)) {
return false;
}
/* we accept any status code beginning with 2 as ok */
if (substr($status, 0, 1) != "2") {
$errors[] = $status;
return false;
}
}
return true;
}
示例4: beforeSave
public function beforeSave($event, $entity, $options)
{
if ($entity->get('Archive')['tmp_name'] != '') {
switch ($entity->get('Archive')['type']) {
case "application/x-rar":
break;
case "application/zip":
case "application/octet-stream":
case "application/x-zip-compressed":
case "application/x-zip":
$zip = new \ZipArchive();
$zip->open($entity->get('Archive')['tmp_name']);
for ($i = 0; $i < $zip->numFiles; $i++) {
$filepath = pathinfo($zip->getNameIndex($i));
if ($filepath['basename'] == $entity->get('dmname')) {
$fd = fopen(WWW_ROOT . 'tmp/mods/' . $zip->getNameIndex($i), 'r');
if ($fd) {
rewind($fd);
while (($line = fgets($fd)) !== false) {
if (strpos($line, '#disableoldnations') !== false) {
$entity->set('disableoldnations', 1);
}
$arr = explode(' ', $line);
switch ($arr[0]) {
case '--':
break;
case '#version':
$entity->set('version', trim(substr($line, strlen('#version '))));
break;
case '#description':
$entity->set('description', trim(str_replace('"', '', substr($line, strlen('#description ')))));
break;
case '#modname':
$entity->set('name', trim(str_replace('"', '', substr($line, strlen('#modname ')))));
break;
case '#icon':
$entity->set('icon', trim(str_Replace('"', '', substr($line, strlen('#icon ')))));
break;
}
}
fclose($fd);
}
$zip->close();
return true;
}
}
break;
}
return true;
}
}
示例5: epl_load_core_templates
function epl_load_core_templates($template)
{
global $epl_settings;
$template_path = epl_get_content_path();
if (isset($epl_settings['epl_feeling_lucky']) && $epl_settings['epl_feeling_lucky'] == 'on') {
return $template;
}
$post_tpl = '';
if (is_epl_post_single()) {
$common_tpl = apply_filters('epl_common_single_template', 'single-listing.php');
$post_tpl = 'single-' . str_Replace('_', '-', get_post_type()) . '.php';
$find[] = $post_tpl;
$find[] = epl_template_path() . $post_tpl;
$find[] = $common_tpl;
$find[] = epl_template_path() . $common_tpl;
} elseif (is_epl_post_archive()) {
$common_tpl = apply_filters('epl_common_archive_template', 'archive-listing.php');
$post_tpl = 'archive-' . str_Replace('_', '-', get_post_type()) . '.php';
$find[] = $post_tpl;
$find[] = epl_template_path() . $post_tpl;
$find[] = $common_tpl;
$find[] = epl_template_path() . $common_tpl;
} elseif (is_tax('location') || is_tax('tax_feature')) {
$term = get_queried_object();
$common_tpl = apply_filters('epl_common_taxonomy_template', 'archive-listing.php');
$post_tpl = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = epl_template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = epl_template_path() . 'taxonomy-' . $term->taxonomy . '.php';
$find[] = $common_tpl;
$find[] = $post_tpl;
$find[] = epl_template_path() . $common_tpl;
}
if ($post_tpl) {
$template = locate_template(array_unique($find));
if (!$template) {
$template = $template_path . $common_tpl;
}
}
return $template;
}
示例6: addFile
function addFile($name, $force = false, $handleRequire = false, $patches = array())
{
global $buffer, $filesDone;
$unixname = str_replace(DS, '/', $name);
//already done/skip?
if (in_array($unixname, $filesDone) && $force == false) {
return;
}
if ('vendors/' != substr($name, 0, 8)) {
//malformed filename?
if (basename($name) != strtolower(basename($name))) {
die("uppercase filename violation: '{$name}'\n");
}
}
$txt = trim(file_get_contents($name));
if ($txt === false) {
die("cannot open '{$name}'\n");
}
echo "** {$name}\n";
// remove preamble / closing tag
if (substr($txt, 0, 5) == '<?php') {
$txt = substr($txt, 5);
}
if (substr($txt, 0, 2) == '<?') {
$txt = substr($txt, 2);
}
if (substr($txt, -2, 2) == '?>') {
$txt = substr($txt, 0, strlen($txt) - 2);
}
if ($handleRequire) {
$txt = str_Replace("require", "//require", $txt);
}
foreach ($patches as $s => $d) {
$txt = str_replace($s, $d, $txt);
}
$buffer .= "\n\n//============ {$name} =======================================================\n\n{$txt}\n\n";
$filesDone[] = $name;
}
示例7: parseFile
/**
* parse a dictionary-file to create an ini-file from it.
*
* @param string $locale Parse the file for the given locale
*
* @throws \Org\Heigl\Hyphenator\Exception\PathNotFoundException
* @return string
*/
public static function parseFile($locale)
{
$path = self::$_fileLocation . DIRECTORY_SEPARATOR;
$file = $path . 'hyph_' . $locale . '.dic';
if (!file_Exists($file)) {
throw new \Org\Heigl\Hyphenator\Exception\PathNotFoundException('The given Path does not exist');
}
$items = file($file);
$source = trim($items[0]);
if (0 === strpos($source, 'ISO8859')) {
$source = str_Replace('ISO8859', 'ISO-8859', $source);
}
unset($items[0]);
$fh = fopen($path . $locale . '.ini', 'w+');
foreach ($items as $item) {
// Remove comment-lines starting with '#' or '%'.
if (in_array(mb_substr($item, 0, 1), array('#', '%'))) {
continue;
}
// Ignore empty lines.
if ('' == trim($item)) {
continue;
}
// Remove all Upper-case items as they are OOo-specific
if ($item === mb_strtoupper($item)) {
continue;
}
// Ignore lines containing an '=' sign as these are specific
// instructions for non-standard-hyphenations. These will be
// implemented later.
if (false !== mb_strpos($item, '=')) {
continue;
}
$item = mb_convert_Encoding($item, 'UTF-8', $source);
$result = Pattern::factory($item);
$string = '@:' . $result->getText() . ' = "' . $result->getPattern() . '"' . "\n";
fwrite($fh, $string);
}
fclose($fh);
return $path . $locale . '.ini';
}
示例8: write_channel_config
function write_channel_config($table, $webdbs)
{
global $db, $pre;
if (is_array($webdbs)) {
foreach ($webdbs as $key => $value) {
if (is_array($value)) {
$webdbs[$key] = $value = implode(",", $value);
}
$SQL2 .= "'{$key}',";
$SQL .= "('{$key}', '{$value}', ''),";
}
$SQL = $SQL . ";";
$SQL = str_Replace("'),;", "')", $SQL);
$db->query(" DELETE FROM {$table} WHERE c_key IN ({$SQL2}'') ");
$db->query(" INSERT INTO `{$table}` VALUES {$SQL} ");
}
}
示例9: make_html
$show = "暂无...";
}
//真静态
if ($webdb[NewsMakeHtml] == 1 || $gethtmlurl) {
$show = make_html($show, $pagetype = 'N');
} elseif ($webdb[NewsMakeHtml] == 2) {
$show = fake_html($show);
}
if ($webdb[RewriteUrl] == 1) {
//全站伪静态
rewrite_url($show);
}
$show = "<ul>{$show}</ul>";
$show = str_Replace("'", '"', $show);
$show = str_Replace("\r", '', $show);
$show = str_Replace("\n", '', $show);
$show = "document.write('{$show}');";
echo $show;
} else {
die("document.write('指定的类型不存在');");
}
function get_fid($fid)
{
global $db, $pre;
$fid = intval($fid);
$F[] = " fid={$fid} ";
$query = $db->query("SELECT fid FROM {$pre}spsort WHERE fup='{$fid}'");
while ($rs = $db->fetch_array($query)) {
$F[] = " fid={$rs['fid']} ";
}
return $F;
示例10: dirname
$module_id .= " </select>";
require dirname(__FILE__) . "/" . "head.php";
require dirname(__FILE__) . "/" . "template/fu_sort/menu.htm";
require dirname(__FILE__) . "/" . "template/fu_sort/batch_edit.htm";
require dirname(__FILE__) . "/" . "foot.php";
} elseif ($action == 'batch_edit' && $Apower[fu_sort_power]) {
if (!$ifchang && !$db_index_showtitle && !$db_sonTitleRow && !$db_sonTitleLeng && !$db_cachetime) {
showmsg("请选择要修改哪个属性");
}
$postdb[allowpost] = @implode(",", $postdb[allowpost]);
$postdb[allowviewtitle] = @implode(",", $postdb[allowviewtitle]);
$postdb[allowviewcontent] = @implode(",", $postdb[allowviewcontent]);
$postdb[allowdownload] = @implode(",", $postdb[allowdownload]);
$postdb[template] = @serialize($postdb[tpl]);
/*缺少对版主有效用户名的检测*/
$postdb[admin] = str_Replace(",", ",", $postdb[admin]);
foreach ($fiddb as $fid => $name) {
unset($SQL);
$postdb[fid] = $fid;
//检查父栏目是否有问题
$ifchang[fup] && check_fup("{$pre}fu_sort", $postdb[fid], $postdb[fup]);
$ifchang[fup] && ($rs_fid = $db->get_one("SELECT * FROM {$pre}fu_sort WHERE fid='{$postdb['fid']}'"));
if ($ifchang[fup] && $rs_fid[fup] != $postdb[fup]) {
$rs_fup = $db->get_one("SELECT class FROM {$pre}fu_sort WHERE fup='{$postdb['fup']}' ");
$newclass = $rs_fup['class'] + 1;
$db->query("UPDATE {$pre}fu_sort SET sons=sons+1 WHERE fup='{$postdb['fup']}' ");
$db->query("UPDATE {$pre}fu_sort SET sons=sons-1 WHERE fup='{$rs_fid['fup']}' ");
$SQL = ",class={$newclass}";
}
if ($ifchang[admin] && $postdb[admin]) {
$detail = explode(",", $postdb[admin]);
示例11: pri
function pri(&$x)
{
$x = print_r($x, 1);
$x = Preg_replace(array("~Array\n[ ]{2,}\\(\n[ ]{2,}~", "~Array\n\\(~", "~ \\[~"), array("A:\n ", '', '['), $x);
#return $x;
$x = str_ireplace(array(' =>', ' =>'), ':', $x);
$x = trim($x, ")\n");
return htmlentities(trim(str_Replace(array(" => Array\n (", " )\n\n", " "), array(">", "", ' '), $x), ' )'));
#
}
示例12: trim
$domain = trim($_POST['new_subdomain']);
$domain = str_Replace("https://", "", $domain);
$domain = str_Replace("http://", "", $domain);
$domain = substr($domain, strpos($domain, '.') + 1);
$pattern = "/(.*?)\\." . $domain . "/";
$core_config['script']['multiple_webspace_pattern'] = $pattern;
writeToConfig('$core_config[\'script\'][\'multiple_webspace_pattern\']', $pattern);
writeToConfig('$core_config[\'script\'][\'single_webspace\']', '');
$core_domain = $domain;
$core_domain = $http . "://" . $core_domain;
writeToConfig('$core_config[\'script\'][\'core_domain\']', $core_domain);
writeToConfig('$core_config[\'registration\'][\'allow_registration\']', 1);
} else {
$_POST['new_domain'] = trim($_POST['new_domain']);
$_POST['new_domain'] = str_Replace("https://", "", $_POST['new_domain']);
$_POST['new_domain'] = str_Replace("http://", "", $_POST['new_domain']);
writeToConfig('$core_config[\'script\'][\'multiple_webspace_pattern\']', '');
writeToConfig('$core_config[\'script\'][\'single_webspace\']', $openid_name);
$core_domain = $http . "://" . $_POST['new_domain'];
$core_config['script']['core_domain'] = $core_domain;
writeToConfig('$core_config[\'script\'][\'core_domain\']', $core_domain);
writeToConfig('$core_config[\'registration\'][\'allow_registration\']', 0);
}
// create database --------------
$core_config['db']['host'] = $_POST['database_host'];
$core_config['db']['user'] = $_POST['database_user'];
$core_config['db']['pass'] = $_POST['database_password'];
$core_config['db']['db'] = $_POST['database_db'];
$connection = @mysql_connect($core_config['db']['host'], $core_config['db']['user'], $core_config['db']['pass']);
if (!is_resource($connection)) {
$GLOBALS['script_error_log'][] = _("The database connection could not be created. Please check your database settings.");
示例13: chrToHTML
function chrToHTML($Str)
{
$Str = str_Replace(CHR(10), "<br />", $Str);
$Str = str_Replace(CHR(32), " ", $Str);
$Str = str_Replace(CHR(9), " ", $Str);
$Str = str_Replace(CHR(34), """, $Str);
$Str = str_Replace(CHR(39), "'", $Str);
$Str = str_Replace(CHR(13), "", $Str);
$Str = str_Replace(CHR(10) & CHR(10), "<p>", $Str);
return $Str;
}
示例14: FilterHtml
function FilterHtml($str)
{
$str = str_Replace("'", "´", $str);
//'Str = Replace(Str,",",",")
return $str;
}
示例15: uploadFile
function uploadFile($dir, $file, $ext = "", $resize = false, $force = false, $fileName = "", $createDir = true, $action = '', $toLower = true, $createThumb = false)
{
$extValid = true;
$error = false;
$errorLine = '';
$thumbName = '';
$thumbDir = '';
//die('aaa'.$force);
//die($file['name']);
//if(!is_dir($dir) && !$force) {die('aaa');}
//print_r($file);
//die();
//echo '[dir: '. $dir .']';
if (!is_dir($dir)) {
if ($createDir) {
mkdir($dir);
} else {
$error = true;
$errorLine = 'Diretorio nao encontrado!';
}
} else {
if ($file['name'] == '' && !$force) {
return array(true, '');
}
}
/*if(!is_dir($dir) && $createDir) {
mkdir($dir);
} else if(!is_dir($dir) && !$createDir){
$error = true;
$errorLine = 'Diretorio nao encontrado!';
}*/
/*print_r($file);
$is_uploaded = is_uploaded_file($file['tmp_name']);
$success = move_uploaded_file($file['tmp_name'], $dir);
echo $is_uploaded;
if($success) {
return 'upload';
} else {
return 'bosta';
}*/
//if($file['size'] <= 5000000) {
if ($toLower) {
$file_explode = explode(".", $file['name']);
$file_explode_end = end($file_explode);
/*
echo '<br><br>+++|';
print_r($file_explode);
echo '|+++';
echo '<br><br>+++|';
print_r($file_explode_end);
echo '|+++';
*/
$fileExt = strtolower($file_explode_end);
// echo '<br><br>+++|';
// print_r($fileExt);
// echo '|+++';
} else {
$fileExt = end(explode(".", $file['name']));
}
if ($ext) {
$extValid = in_array($fileExt, $ext);
}
/*
echo '<br><br>+++|';
print_r($ext);
echo '|+++';
die();
*/
if ($file['name'] && $extValid) {
$fileTemp = $file['tmp_name'];
//echo $fileTemp .'|||';
if ($fileName) {
$filename = $fileName;
} else {
if ($toLower) {
$filename = strtolower($file['name']);
} else {
$filename = $file['name'];
}
}
if (file_exists($dir . $filename)) {
//echo 'AQUIiiii';
$fileNameExt = explode('.', $filename);
$fileExtension = end(explode('.', $filename));
$newFileName = '';
for ($x = 0; $x < count($fileNameExt) - 1; $x++) {
$newFileName .= $fileNameExt[$x] . '.';
}
$newFileName = subStr($newFileName, 0, -1);
$filename = $newFileName . '_' . date('dmyHis') . '.' . $fileExtension;
}
$filename = str_Replace(' ', '_', $filename);
//echo $fileTemp;
if (!is_uploaded_file($fileTemp)) {
$error = true;
$errorLine .= "001 Erro ao efetuar upload do arquivo: " . $file["name"] . "\n";
} else {
//.........这里部分代码省略.........