PHP intercepts Chinese string functions ~ including GB2312 and UT-8
/*
Chinese character interception function supported by Utf-8 and gb2312
Cut_str (string, intercept length, start length, encode);
encoding defaults to Utf-8
Start length defaults
PHP Common string manipulation functionsstring Conversion class functionsaddcslashes function: Use backslash to escape characters in a string in C language styleaddslashes function: Using a backslash to reference a stringChop function: Clears
function
Description
Addcslashes ()
Returns a string that adds a backslash before the specified character.
Addslashes ()
Returns a string that adds a backslash before a predefined character.
PHP String processing function DaquanAddcslashes-adds a backslash escape character for some characters inside a stringaddslashes-characters inside a string are escaped in the specified mannerbin2hex-converts binary data to hexadecimal notationalias
Nl2brFunction: of line breakRTrimFunction: Clear the blank on the right "; $result = RTrim ($STR); Echo strlen ($result);/** results 1411*/Strip_tagsFunction: Clear the HTML and PHP tags in the stringhello world"; $result = Strip_tags ($STR); echo $
1: The code is as follows//6.15.cpp: Defines the entry point of the console application. //#include"stdafx.h"#includeusing namespacestd;voidMain () {Charstr1[ -], str2[ -], *P1, *P2; P1=str1; P2=str2; cout"Please input string1:"Endl; gets_s (STR1)
1, First letter capital' GHOSTWU '>>> s.capitalize ()'ghostwu'2,replace, replacing>>> s ='My name is GHOSTWU'>>>s'My name is GHOSTWU'>>> S.replace (' -',' -' )'My name is GHOSTWU'>>>s'My name is GHOSTWU'>>>Check Help>>> Help (Str.replace)If it is a
Substringpublic string substring (int beginindex) returns a new string that is a substring of this string. The substring starts at the specified index and continues to the end of the string.For example:"Unhappy". SUBSTRING (2) returns
(1) Capitlize function (change the first letter of the string to uppercase)1 ' Doudizhu ' 2 v = h.capitalize ()3print(v)Output is: Doudizhu(2) lower function (lowercase all letters in a string)1 ' Doudizhu ' 2 v = h.lower ()3print(v)Output is:
There are four ways: 1. Using heap space, return the requested heap address, and note release 2. The function parameter passes a pointer that returns the pointer 3. Returns a static variable (shared) 4 defined within a function. Returning a global
Split function: Splitting a string into a sequenceStr.split ("delimiter")It is generally possible to use list = [n for n in Str.split] so that a new sequence can be obtainedStrip function: Remove the space characters on both sides, if the strip with
There are a lot of cut string functions, but according to Chinese cut string is very little, in this article will introduce you how to use PHP to achieve, interested friends do not miss the code as follows: Define (CHARSET, ' UTF-8 '); System
A string or string (string) is a finite sequence consisting of 0 or more characters. Generally recorded as s= ' a1a2 an ' (n>=0). It is the data type that represents text in the programming language.
A string is usually used as an action object,
Intercepting string functions in Web effects
function Substrdemo () {var s, SS; Declare a variable.var s = "The rain in Spain falls mainly in the plain.";SS = S.substr (12, 5); Gets the substring.return (SS); Returns "Spain".}
b =
Objective
There are four ways to return string functions in the C language, respectively:
Use heap space, return the heap address of the application, pay attention to release
function parameter passes the pointer and returns the pointer
Conditional Functions
The following table provides some of the conditional functions that hive supports.
return type
Name of function
Description
T
If (Boolean testcondition, T valuetrue, T Valuefalseornull)
value FunctionSyntax: VALUE (Expression1,expression2)The value function is returned with a non-null value, and when its first argument is not NULL, it returns the values of the parameter directly, and if the first argument is null, the value of the
value FunctionSyntax: VALUE (Expression1,expression2)The value function is returned with a non-null value, and when its first argument is not NULL, it returns the values of the parameter directly, and if the first argument is null, the value of the
Http://www.jb51.net/article/27458.htm
It feels like MySQL's string function intercepts characters, and is more powerful than a program intercept (like PHP or Java), so make a record here and hope it works for everyone.Function:1. Intercept
Select Initcap (' Guodongdong ') from dual; /returns a string and capitalizes the first letter of the string;Select Initcap (ename) from Scott.emp; /start all uppercase for ename in the Scott.emp table.Select Lower (ename) from scott.emp;/all
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.