本文整理汇总了PHP中LTrim函数的典型用法代码示例。如果您正苦于以下问题:PHP LTrim函数的具体用法?PHP LTrim怎么用?PHP LTrim使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LTrim函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OnSearchGetURL
function OnSearchGetURL($arFields)
{
global $DB, $BX_NEWS_DETAIL_URL, $BX_NEWS_SECTION_URL;
static $arIBlockCache = array();
if ($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=") {
return $arFields["URL"];
}
if (!CModule::IncludeModule('iblock')) {
return "";
}
$IBLOCK_ID = IntVal($arFields["PARAM2"]);
if (!array_key_exists($IBLOCK_ID, $arIBlockCache)) {
$res = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tDETAIL_PAGE_URL,\n\t\t\t\t\tSECTION_PAGE_URL,\n\t\t\t\t\tCODE as IBLOCK_CODE,\n\t\t\t\t\tXML_ID as IBLOCK_EXTERNAL_ID,\n\t\t\t\t\tIBLOCK_TYPE_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock\n\t\t\t\tWHERE ID = " . $IBLOCK_ID . "\n\t\t\t");
$arIBlockCache[$IBLOCK_ID] = $res->Fetch();
}
if (!is_array($arIBlockCache[$IBLOCK_ID])) {
return "";
}
$arFields["URL"] = LTrim($arFields["URL"], " =");
parse_str($arFields["URL"], $arr);
$arr = $arIBlockCache[$IBLOCK_ID] + $arr;
$arr["LANG_DIR"] = $arFields["DIR"];
if (substr($arFields["ITEM_ID"], 0, 1) !== 'S') {
return CIBlock::ReplaceDetailUrl($BX_NEWS_DETAIL_URL, $arr, true, "E");
} else {
return CIBlock::ReplaceDetailUrl($BX_NEWS_SECTION_URL, $arr, true, "S");
}
}
示例2: defineRewriteRules
static function defineRewriteRules()
{
# Add filter permalink structure for post type archive
$post_type = Get_Post_Type_Object(Post_Type::$post_type_name);
$archive_url_path = $post_type->rewrite['slug'];
self::$rewrite_rules[LTrim(SPrintF('%s/filter:([^/]+)/?$', $archive_url_path), '/')] = SPrintF('index.php?post_type=%s&filter=$matches[1]', Post_Type::$post_type_name);
self::$rewrite_rules[LTrim(SPrintF('%s/filter:([^/]+)/page/([0-9]{1,})/?$', $archive_url_path), '/')] = SPrintF('index.php?post_type=%s&filter=$matches[1]&paged=$matches[2]', Post_Type::$post_type_name);
# Add filter permalink structure for taxonomy archives
foreach (Get_Taxonomies(Null, 'objects') as $taxonomy) {
$taxonomy_slug = $taxonomy->rewrite['slug'];
if (!In_Array(Post_Type::$post_type_name, $taxonomy->object_type)) {
continue;
}
self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]', $taxonomy->name);
self::$rewrite_rules[LTrim(SPrintF('%s/([^/]+)/filter:([^/]+)/page/([0-9]{1,})/?$', $taxonomy_slug), '/')] = SPrintF('index.php?%s=$matches[1]&filter=$matches[2]&paged=$matches[3]', $taxonomy->name);
}
}
示例3: OnSearchGetURL
function OnSearchGetURL($arFields)
{
/** @global CDatabase $DB */
global $DB;
static $arIBlockCache = array();
if($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=")
return $arFields["URL"];
$IBLOCK_ID = IntVal($arFields["PARAM2"]);
if(!array_key_exists($IBLOCK_ID, $arIBlockCache))
{
$res = $DB->Query("
SELECT
DETAIL_PAGE_URL,
SECTION_PAGE_URL,
CODE as IBLOCK_CODE,
XML_ID as IBLOCK_EXTERNAL_ID,
IBLOCK_TYPE_ID
FROM
b_iblock
WHERE ID = ".$IBLOCK_ID."
");
$arIBlockCache[$IBLOCK_ID] = $res->Fetch();
}
if(!is_array($arIBlockCache[$IBLOCK_ID]))
return "";
$arFields["URL"] = LTrim($arFields["URL"], " =");
parse_str($arFields["URL"], $arr);
$arr = $arIBlockCache[$IBLOCK_ID] + $arr;
$arr["LANG_DIR"] = $arFields["DIR"];
if(substr($arFields["ITEM_ID"], 0, 1) !== 'S')
return CIBlock::ReplaceDetailUrl($arIBlockCache[$IBLOCK_ID]["DETAIL_PAGE_URL"], $arr, false, "E");
else
return CIBlock::ReplaceDetailUrl($arIBlockCache[$IBLOCK_ID]["SECTION_PAGE_URL"], $arr, false, "S");
}
示例4: GetSiteSwitcherArray
function GetSiteSwitcherArray()
{
$cur_dir = $this->GetCurDir();
$cur_page = $this->GetCurPage();
$bAdmin = substr($cur_dir, 0, strlen(BX_ROOT . "/admin/")) == BX_ROOT . "/admin/";
$path_without_lang = $path_without_lang_tmp = "";
$db_res = CSite::GetList($by, $order, array("ACTIVE" => "Y", "ID" => LANG));
if (($ar = $db_res->Fetch()) && strpos($cur_page, $ar["DIR"]) === 0) {
$path_without_lang = substr($cur_page, strlen($ar["DIR"]) - 1);
$path_without_lang = LTrim($path_without_lang, "/");
$path_without_lang_tmp = RTrim($path_without_lang, "/");
}
$result = array();
$db_res = CSite::GetList($by = "SORT", $order = "ASC", array("ACTIVE" => "Y"));
while ($ar = $db_res->Fetch()) {
$ar["NAME"] = htmlspecialcharsbx($ar["NAME"]);
$ar["SELECTED"] = $ar["LID"] == LANG;
if ($bAdmin) {
global $QUERY_STRING;
$p = rtrim(str_replace("&#", "#", preg_replace("/lang=[^&#]*&*/", "", $QUERY_STRING)), "&");
$ar["PATH"] = $this->GetCurPage() . "?lang=" . $ar["LID"] . ($p != '' ? '&' . $p : '');
} else {
$ar["PATH"] = "";
if (strlen($path_without_lang) > 1 && file_exists($ar["ABS_DOC_ROOT"] . "/" . $ar["DIR"] . "/" . $path_without_lang_tmp)) {
$ar["PATH"] = $ar["DIR"] . $path_without_lang;
}
if (strlen($ar["PATH"]) <= 0) {
$ar["PATH"] = $ar["DIR"];
}
if ($ar["ABS_DOC_ROOT"] !== $_SERVER["DOCUMENT_ROOT"]) {
$ar["FULL_URL"] = (CMain::IsHTTPS() ? "https://" : "http://") . $ar["SERVER_NAME"] . $ar["PATH"];
} else {
$ar["FULL_URL"] = $ar["PATH"];
}
}
$result[] = $ar;
}
return $result;
}
示例5: FindConfigElem
function FindConfigElem(&$cfg_file, $elem_name)
{
$cfg_info = array();
$inside = 0;
for ($i = 0; $i < Count($cfg_file); $i++) {
$cfg_line = $cfg_file[$i];
$cfg_line = RTrim($cfg_line);
$cfg_line = LTrim($cfg_line);
if (!$cfg_line) {
// Blank line
continue;
} elseif (Preg_Match("/^(\\/\\/|#)/", $cfg_line)) {
//Comment line
continue;
} elseif (Preg_Match("/^(([[:alnum:]]+)\\s+({$elem_name})|{$elem_name})\$/i", $cfg_line, $matches)) {
$next_line = RTrim($cfg_file[$i + 1]);
if (!Preg_Match("/\\s*\\{\\s*/i", $next_line)) {
// Not an elem line - maybe a property line with no spaces infront of it.
continue;
}
//Print("Inside (0){$matches[0]} (1){$matches[1]} (2){$matches[2]} (3){$matches[3]}\n");
//It is inside the elem that it has been told to read.
$inside = 1;
} elseif ($inside) {
if (Preg_Match("/^{/i", $cfg_line)) {
//Ignore the { line
continue;
} elseif (Preg_Match("/^}/i", $cfg_line)) {
//It reached the } line, which means it is done reading the elem.
//Stop going through the rest of the file at this point.
$inside = 0;
break;
} else {
//It is still inside the elem's brackets.
//Split the lines up into key value pairs.
//Tuck the values into the array[key]
$info = Preg_Split("/\\s+/", $cfg_line, 2, PREG_SPLIT_NO_EMPTY);
$key = $info[0];
$value = $info[1];
if (!Is_Array($cfg_info[$key])) {
// If cfg_info[key] is not already an array,
// make it one so it can hold multiple values.
$cfg_info[$key] = array();
}
Array_Push($cfg_info[$key], $value);
}
}
}
if (Count($cfg_info) < 1) {
return FALSE;
} else {
return $cfg_info;
}
}
示例6: Trim
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VerliAdmin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
======================================================================
*/
$continue = TRUE;
$_POST['command'] = Trim($_POST['command']);
IF(($command = SubStr($_POST['command'], 0, StrPos($_POST['command'], " "))) == FALSE)
$command = $_POST['command'];
$param = LTrim(StrStr($_POST['command'], " "));
//Print "'".$command."' - '".$param."' - '".$_POST['command']."'";
SWITCH(StrToLower($command)) {
//---------------------------------------------------------------------
// +passwd
CASE "+passwd" :
$password = $param;
IF(!PasswordChange($password, $password, $nick, 1)) {
VA_Alert($err_msg_pwd_ch_not_allowed, "error", "index.php?".Change_URL_Query("q", $_GET['return'], "return", ""));
$continue = FALSE;
}
BREAK;