本文整理汇总了PHP中Str_Replace函数的典型用法代码示例。如果您正苦于以下问题:PHP Str_Replace函数的具体用法?PHP Str_Replace怎么用?PHP Str_Replace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Str_Replace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WhoIs_Parse
function WhoIs_Parse($Domain)
{
#-------------------------------------------------------------------------------
Debug(SPrintF('[system/libs/WhoIs]: run function WhoIs_Parse, Domain = %s', $Domain));
#-------------------------------------------------------------------------------
$Regulars = Regulars();
#-------------------------------------------------------------------------------
if (!Preg_Match($Regulars['Domain'], $Domain)) {
return new gException('WRONG_DOMAIN_NAME', 'Неверное доменное имя');
}
#-------------------------------------------------------------------------------
$DomainZones = System_XML('config/DomainZones.xml');
if (Is_Error($DomainZones)) {
return ERROR | @Trigger_Error('[WhoIs_Parse]: не удалось загрузить базу WhoIs серверов');
}
#-------------------------------------------------------------------------------
foreach ($DomainZones as $DomainZone) {
#-------------------------------------------------------------------------------
$Name = $DomainZone['Name'];
#-------------------------------------------------------------------------------
if (Preg_Match(SPrintF('/^([0-9a-zабвгдеёжзийклмнопрстуфхцчшщьыъэюя\\-]+)\\.%s$/', Str_Replace('.', '\\.', $Name)), $Domain, $Matches)) {
return array('DomainName' => Next($Matches), 'DomainZone' => $DomainZone['Name']);
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
return FALSE;
#-------------------------------------------------------------------------------
}
示例2: __construct
public function __construct($core)
{
$this->core = $core;
$this->page_slug = Sanitize_Title(Str_Replace(array('\\', '/', '_'), '-', __CLASS__));
# Option boxes
$this->arr_option_box = array('main' => array(), 'side' => array());
Add_Action('admin_menu', array($this, 'Add_Options_Page'));
}
示例3: title2pagename
public static function title2pagename($text)
{
$znaky = array('á' => 'a', 'é' => 'e', 'ě' => 'e', 'í' => 'i', 'ó' => 'o', 'ú' => 'u', 'ů' => 'u', 'ý' => 'y', 'ž' => 'z', 'š' => 's', 'č' => 'c', 'ř' => 'r', 'Á' => 'A', 'É' => 'E', 'Ě' => 'E', 'Í' => 'I', 'Ó' => 'O', 'Ú' => 'U', 'Ů' => 'U', 'Ý' => 'Y', 'Ž' => 'Z', 'Š' => 'S', 'Č' => 'C', 'Ř' => 'R');
$return = strtr($text, $znaky);
$return = Str_Replace(" ", "", $return);
//smaze mezery
$return = StrToLower($return);
//velká písmena nahradí malými.
return $return;
}
示例4: loadBaseURL
static function loadBaseURL()
{
$absolute_plugin_folder = RealPath(self::$plugin_folder);
if (StrPos($absolute_plugin_folder, ABSPATH) === 0) {
self::$base_url = Get_Bloginfo('wpurl') . '/' . SubStr($absolute_plugin_folder, Strlen(ABSPATH));
} else {
self::$base_url = Plugins_Url(BaseName(self::$plugin_folder));
}
self::$base_url = Str_Replace("\\", '/', self::$base_url);
# Windows Workaround
}
示例5: friendly_url
public static function friendly_url($text)
{
$friendlyurl = Str_Replace(' ', '-', AddSlashes($text));
$tbl = array("á" => "a", "ä" => "a", "č" => "c", "ď" => "d", "é" => "e", "ě" => "e", "í" => "i", "ľ" => "l", "ĺ" => "l", "ň" => "n", "ó" => "o", "ö" => "o", "ő" => "o", "ô" => "o", "ř" => "r", "ŕ" => "r", "š" => "s", "ť" => "t", "ú" => "u", "ů" => "u", "ü" => "u", "ű" => "u", "ý" => "y", "ž" => "z", "Á" => "A", "Ä" => "A", "Č" => "C", "Ď" => "D", "É" => "E", "Ě" => "E", "Í" => "I", "Ľ" => "L", "Ĺ" => "L", "Ň" => "N", "Ó" => "O", "Ö" => "O", "Ő" => "O", "Ô" => "O", "Ř" => "R", "Ŕ" => "R", "Š" => "S", "Ť" => "T", "Ú" => "U", "Ů" => "U", "Ü" => "U", "Ű" => "U", "Ý" => "Y", "Ž" => "Z", "'" => "", ",-" => "kc");
$url = StrTr($friendlyurl, $tbl);
$text = StrTr($url, "ÁÄČÇĎÉĚËÍŇÓÖŘŠŤÚŮÜÝŽáäčçďéěëíňóöřšťúůüýž", "AACCDEEEINOORSTUUUYZaaccdeeeinoorstuuuyz");
// somehow I wasnt able to add following characters to previous StrTr strings:
$text = StrTr($text, "& .,?!_+", "--------");
//$text = Preg_Replace ("/[^[:alpha:][:digit:]]/", "-", $text);
$text = Trim($text, "-");
$text = Preg_Replace("/[-]+/", "-", $text);
return strtolower($text);
}
示例6: __construct
function __construct()
{
if (Is_Admin() && !$this->Validate_Licence()) {
$this->base_url = get_bloginfo('wpurl') . '/' . Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH)));
Add_Action('admin_init', array($this, 'Load_TextDomain'));
Add_Action('admin_init', array($this, 'Add_Contribution_Code_Field'));
Add_Action('admin_print_footer_scripts', array($this, 'Print_Contribution_JS'), 99);
Add_Action('admin_notices', array($this, 'Print_Contribution_Form'), 1);
Add_Action('wp_dashboard_setup', array($this, 'Register_Dashboard_Widget'), 9);
Add_Action('donation_message', array($this, 'Print_Contribution_Message'));
Add_Action('dh_contribution_message', array($this, 'Print_Contribution_Message'));
}
$this->Check_Remote_Activation();
}
示例7: Table_Super_Replace
function Table_Super_Replace($Array, $Matches)
{
#---------------------------------------------------------------------------
$Result = array();
#---------------------------------------------------------------------------
if (Is_Array($Array)) {
#-------------------------------------------------------------------------
foreach (Array_Keys($Array) as $ElementID) {
#-----------------------------------------------------------------------
$Element = $Array[$ElementID];
#-----------------------------------------------------------------------
$Result[$ElementID] = Is_Array($Element) ? Table_Super_Replace($Element, $Matches) : Str_Replace(Array_Keys($Matches), Array_Values($Matches), $Element);
}
}
#---------------------------------------------------------------------------
return $Result;
}
示例8: __construct
function __construct()
{
// Read base
$this->base_url = get_bloginfo('wpurl') . '/' . Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH)));
// Get ready to translate
$this->Load_TextDomain();
// Set Hooks
if (Is_Admin()) {
Add_Action('admin_menu', array($this, 'add_options_page'));
Add_Action('admin_head', array($this, 'print_admin_header'));
} else {
Add_Action('wp_head', array($this, 'print_header'));
Add_ShortCode('gallery', array($this, 'gallery_shortcode'));
}
// Add jQuery
wp_enqueue_script('jquery');
}
示例9: HexToRGB
function HexToRGB($color)
{
// Delete the # symbol
$input = Trim(Str_Replace("#", "", StrToUpper($color)));
// Get every single number-letter
$a = $this->_convertToDecimal($input[0]);
$b = $this->_convertToDecimal($input[1]);
$c = $this->_convertToDecimal($input[2]);
$d = $this->_convertToDecimal($input[3]);
$e = $this->_convertToDecimal($input[4]);
$f = $this->_convertToDecimal($input[5]);
// Build the RGB code
$r = $a * 16 + $b;
$g = $c * 16 + $d;
$b = $e * 16 + $f;
// Put R, G and B in an array for separate use
$RGB = array($r, $g, $b);
return $RGB;
}
示例10: TemplateReplace
function TemplateReplace($Text, $Params = array(), $NoBody = TRUE)
{
#-------------------------------------------------------------------------------
$Text = Trim($Text);
#-------------------------------------------------------------------------------
# проверяем что нам сунули - текст или файл
if (!Preg_Match('/\\s/', $Text)) {
#-------------------------------------------------------------------------------
# достаём текст из файла
$Path = System_Element(SPrintF('templates/modules/%s.html', $Text));
#-------------------------------------------------------------------------------
if (Is_Error($Path)) {
#-------------------------------------------------------------------------------
$Text = SprintF('Отсутствует шаблон сообщения (templates/modules/%s.html)', $Text);
#-------------------------------------------------------------------------------
} else {
#-------------------------------------------------------------------------------
$Text = Trim(IO_Read($Path));
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
if ($NoBody) {
$Text = SPrintF('<NOBODY><SPAN>%s</SPAN></NOBODY>', $Text);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Replace = Array_ToLine($Params, '%');
#-------------------------------------------------------------------------------
foreach (Array_Keys($Replace) as $Key) {
$Text = Str_Replace($Key, $Replace[$Key], $Text);
}
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
return $Text;
#-------------------------------------------------------------------------------
}
示例11: array
#-------------------------------------------------------------------------------
/** @author Великодный В.В. (Joonte Ltd.) */
/******************************************************************************/
/******************************************************************************/
$__args_list = array('LinkID', 'Text');
/******************************************************************************/
/******************************************************************************/
/******************************************************************************/
eval(COMP_INIT);
/******************************************************************************/
/******************************************************************************/
$Links =& Links();
#-------------------------------------------------------------------------------
$Object =& $Links[$LinkID];
#-------------------------------------------------------------------------------
$Object->AddAttribs(array('onmouseover' => SPrintF("PromptShow(event,'%s',this);", AddcSlashes(Str_Replace("\n", '<BR />', $Text), "\n\r\\\\'"))));
#-------------------------------------------------------------------------------
if (!Comp_IsLoaded('Form/Prompt')) {
#-----------------------------------------------------------------------------
$DOM =& $Links['DOM'];
#-----------------------------------------------------------------------------
$Script = new Tag('SCRIPT', array('type' => 'text/javascript', 'src' => 'SRC:{Js/Prompt.js}'));
#-----------------------------------------------------------------------------
$DOM->AddChild('Head', $Script);
#-----------------------------------------------------------------------------
$Comp = Comp_Load('Css', array('Prompt'));
if (Is_Error($Comp)) {
return ERROR | @Trigger_Error(500);
}
#-----------------------------------------------------------------------------
foreach ($Comp as $Css) {
示例12: SearchUserByName
private function SearchUserByName($user)
{
$user = trim($user);
if (strlen($user) <= 0) {
return array();
}
$userId = 0;
if ($user . "|" == intval($user) . "|") {
$userId = intval($user);
}
if ($userId <= 0) {
$arMatches = array();
if (preg_match("#\\[(\\d+)\\]#i", $user, $arMatches)) {
$userId = intval($arMatches[1]);
}
}
$arResult = array();
$dbUsers = false;
if ($userId > 0) {
$arFilter = array("ID_EQUAL_EXACT" => $userId);
$dbUsers = CUser::GetList($by = "LAST_NAME", $order = "asc", $arFilter, array("NAV_PARAMS" => false));
} else {
$userLogin = "";
$arMatches = array();
if (preg_match("#\\((.+?)\\)#i", $user, $arMatches)) {
$userLogin = $arMatches[1];
$user = trim(str_replace("(" . $userLogin . ")", "", $user));
}
$userEmail = "";
$arMatches = array();
if (preg_match("#<(.+?)>#i", $user, $arMatches)) {
if (check_email($arMatches[1])) {
$userEmail = $arMatches[1];
$user = Trim(Str_Replace("<" . $userEmail . ">", "", $user));
}
}
$arUser = array();
$arUserTmp = Explode(" ", $user);
foreach ($arUserTmp as $s) {
$s = Trim($s);
if (StrLen($s) > 0) {
$arUser[] = $s;
}
}
if (strlen($userLogin) > 0) {
$arUser[] = $userLogin;
}
$dbUsers = CUser::SearchUserByName($arUser, $userEmail, true);
}
if ($dbUsers) {
while ($arUsers = $dbUsers->GetNext()) {
$arResult[] = $arUsers["ID"];
}
}
return $arResult;
}
示例13: InitGroupsTmp
public static function InitGroupsTmp($message, $titleTemplate1, $titleTemplate2, $arParams, $bRSS = false)
{
$arGroupsID = explode(",", $message);
$message = "";
$title = "";
$bFirst = true;
$count = 0;
foreach ($arGroupsID as $groupID)
{
list($titleTmp, $messageTmp) = CSocNetLog::InitGroupTmp($groupID, $arParams, $bRSS);
if (StrLen($titleTmp) > 0)
{
if (!$bFirst)
$title .= ", ";
$title .= $titleTmp;
$count++;
}
if (StrLen($messageTmp) > 0)
{
if (!$bFirst)
$message .= " ";
$message .= $messageTmp;
}
$bFirst = false;
}
return array(Str_Replace("#TITLE#", $title, (($count > 1) ? $titleTemplate2 : $titleTemplate1)), $message);
}
示例14: switch
#-------------------------------------------------------------------------------
switch (ValueOf($Contract)) {
case 'error':
return ERROR | @Trigger_Error(500);
case 'exception':
return new gException('CONTRACT_NOT_FOUND', 'Договора не найдены');
case 'array':
break;
default:
return ERROR | @Trigger_Error(101);
}
#-------------------------------------------------------------------------------
Debug(SPrintF('[comp/Tasks/GC/WithdrawalOldUsers]: юзер (%s), договор #%u, балланс %s', $User['Email'], $Contract['ID'], $Contract['Balance']));
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
$Settings['WithdrawSumm'] = Str_Replace(',', '.', $Settings['WithdrawSumm']);
#-------------------------------------------------------------------------------
$Summ = $Contract['Balance'] > $Settings['WithdrawSumm'] ? $Settings['WithdrawSumm'] : $Contract['Balance'];
#-------------------------------------------------------------------------------
$IsUpdate = Comp_Load('www/Administrator/API/PostingMake', array('ContractID' => $Contract['ID'], 'Summ' => -$Summ, 'ServiceID' => 2100, 'Comment' => SPrintF('Хранение клиентской информации за период %s', Date('Y/m', MkTime(4, 0, 0, Date('n') - 1, 5, Date('Y'))))));
#-------------------------------------------------------------------------------
switch (ValueOf($IsUpdate)) {
case 'error':
return ERROR | @Trigger_Error(500);
case 'exception':
return ERROR | @Trigger_Error(400);
case 'array':
break;
default:
return ERROR | @Trigger_Error(101);
}
示例15: Explode
$lang = Explode("|", $file[$i]);
$lang[1] = MySQL_Escape_String($lang[1]);
Query("INSERT delayed ignore INTO va_languages VALUES ('lv', '".$lang[0]."', '".$lang[1]."', '".$lang[2]."')") OR Die("#".MySQL_ErrNo()." : ".MySQL_Error());
}
FOR($i = 0; $i < Count($file_en); $i++) {
$file_en[$i] = Ereg_Replace("([\$\"\;\t])", "", $file_en[$i]);
$file_en[$i] = Str_Replace("( =)|(\\\\)", "|", $file_en[$i]);
$lang = Explode("|", $file_en[$i]);
$lang[1] = MySQL_Escape_String($lang[1]);
Query("INSERT delayed ignore INTO va_languages VALUES ('lv', '".$lang[0]."', '".$lang[1]."', '".$lang[2]."')") OR Die("#".MySQL_ErrNo()." : ".MySQL_Error());
}
UnSet($file);
$file = File("scripts/languages/it.php");
FOR($i = 0; $i < Count($file); $i++) {
$file[$i] = Ereg_Replace("([\$\"\;\t])", "", $file[$i]);
$file[$i] = Str_Replace(" =", "|", $file[$i]);
$lang = Explode("|", $file[$i]);
$lang[1] = MySQL_Escape_String($lang[1]);
Query("INSERT delayed ignore INTO va_languages VALUES ('it', '".$lang[0]."', '".$lang[1]."', '".$lang[2]."')") OR Die("#".MySQL_ErrNo()." : ".MySQL_Error());
}
FOR($i = 0; $i < Count($file_en); $i++) {
$file_en[$i] = Ereg_Replace("([\$\"\;\t])", "", $file_en[$i]);
$file_en[$i] = Str_Replace("( =)|(\\\\)", "|", $file_en[$i]);
$lang = Explode("|", $file_en[$i]);
$lang[1] = MySQL_Escape_String($lang[1]);
Query("INSERT delayed ignore INTO va_languages VALUES ('it', '".$lang[0]."', '".$lang[1]."', '".$lang[2]."')") OR Die("#".MySQL_ErrNo()." : ".MySQL_Error());
}
?>