The string is a sequence of characters, such as "Hello world!". PHP String FunctionsIn this section, we will learn about commonly used string manipulation functions. PHP strlen () functionThe strlen () function returns the length of a string, measured in characters.The follo
With a simple understanding of the PHP data type in the previous article, we know the string type, this article will introduce the string functions commonly used in PHP.The string is a sequence of characters, such as "Hello world!".PHP String FunctionsWhat is the role of
In PHP, there are two functions related to the escape of strings: addslashes and stripslashes.
Addslashes ($ string), which is used to add a backslash (\) before a specified predefined character to prepare a suitable string for the string stored in the database and the database query statement.
Note: by default, the ma
= 1 bit, 2 English = 1 bit, you can modify it yourself
The code is as follows:
/*** PHP obtains a string with a mix of Chinese and English characters * @ param $ str string * @ param $ charset string encoding * @ return returns the length. 1 Chinese character = 1 character, 2 English = 1 digit */function strLength ($ str, $ charset = 'utf-8') {if ($ charset = 'u
Here are just a few simple and common functions, chop performs the removal of whitespace processing, get_html_translation_table returns a conversion list to a variable, and defines a string that includes HTML encoding Htmlentities,htmlspecialchars_ Decode defines strings that contain HTML special characters, NL2BR Quotemeta RTrim, and so on.
Here are just a few simple and common
(‘currency.txt‘,‘w‘))){return;}$money1=68.75;$money2=54.35;$money=$money1+$money2;//echo$moneywilloutput"123.1";$len=fprintf($fp,‘%01.2f‘,$money);//willwrite"123.10"tocurrency.txtecho"wrote$lenbytestocurrency.txt";//usethereturnvalueoffprintftodeterminehowmanybyteswewrote?>Function Five:get_html_translation_table- returns the conversion table after using Htmlspecialchars () and htmlentities (). Descriptionarray get_html_translation_table ([ int $table = html_specialchars [, int $quote_style = E
Common javascript string functions
The most common string methods are: indexof (), charat (), and substring ()Indexof () function:
This function allows you to determine whether a string exists in a longer string and its location. It is equivalent to the strstr function in C
Label:Chat_length (s) Returns the number of characters in the string s Concat (S1,s2,..) Combine strings s1,s2 and more into a single string Cincat_ws (X,s1,s2,....) Tong Concat (S1,s2,..) function, but the x is added between each string Insert (S1,X,LEN,S2) Strong string S2 replaces S1 's x position starting at Len
This article mainly introduces the summary of common string formatting functions in PHP. the functions described in this article are frequently used on the WEB, for example, functions such as space filling and string filling, case-sensitive conversion of strings, and
The following provides only a few simple and commonly used functions. chop removes spaces and get_html_translation_table returns the conversion list to the variable. It defines the HTML-encoded string htmlentities and htmlspecialchars_decode to define a string containing special HTML characters, nl2br quotemeta rtrim.
The following provides only a few simple and
Function
The function of the camelCase function is to convert the form of background-color to the camelCase Notation: backgroundColor.
This function is useful in jQuery data functions and many functions related to css.
JQuery implementationCopy codeThe Code is as follows: // Regular Expression matchingRdashAlpha =/-([a-z])/ig,// Callback function when camelCase replaces the stringFcamelCase = function (all
two methods of output split string the performance of the results will be slightly different.
Composite string
The implode () function can combine the contents of an array into a new string.
The syntax format is as follows:
Implode (Separator,array)
The parameter separator is optional. Specifies what is placed between the elements of the array. The default is ""
=strdup ("AFNKSF");//printf ("%s\n", b); //S1,s2 is a string when memcmp (s1,s2,1) is the first byte of the comparison S1 and S2 ASCII code value;//printf ("%d\n", memcmp ("AVC", "DDS", 1)); //used to find the C string needle in the C string haystack, ignoring the case. A char pointer that returns the position of the first occurrence of the needle
The PHP string function includes the lookup character position function, extracts the child character function, replaces the string, the character length, compares the character function, splits the array character, removes the space and so on.
The string function in the PHP language is also a fairly understandable knowledge. Today we have summed up nearly 12 ki
Use of PHP string-based comparison functions strcmp () and strcasecmp. The difference between "" and "" is simply that the former emphasizes that the "identical (same, identical)" type also requires the same; the latter requires "equal (equal to" = "for judgment. The difference between" = "and" = "is simply that the former emphasizes" identical (identical, identical) "type also requires the same; the latter
1 Find the character position function:
Strpos ($str, $seach, [int]); Find the first position of search in $str starting with int;
Stripos ($str, $seach, [int]); The function returns the position of the first occurrence of the string in another string. This function is not sensitive to case
Strrpos ($str, Search,[int]): Find where the last occurrence of search in $STR starts with int
Strripos ($str, Search,
: This article mainly introduces php string functions (1). For more information about PHP tutorials, see. 1. clear spaces and characters on both sides of the string. the trim () function ()
$ Str = "hello, word"; echo $ str .""; Echo trim ($ str ).""; $ Str =" @ dawn hello, word @ "; echo ltrim ($ str ).""; Echo rtrim ($ str );
The result is as follows: ltrim ()
This article mainly introduces how PHP functions extract keywords from a text string, involving php's string traversal and search operations. For more information, see
This article mainly introduces how PHP functions extract keywords from a text string, involving php's
reference to S, S has been destroyed, RS returns a garbled value. The expression is formed because the return value is a reference, the reference is an lvalue, and can be referenced by an lvalue reference.5.string Getmem () { string"HelloWorld"; String rs = s; return rs;}string ss = Getmem (); correctly, th
the string to replace. Displays only the results, which do not affect the database data .Select REPLACE(Test,'8','two points') fromXueshengxinxi--REPLICATE Copy, can replicate 0-n times, equivalent to cut and then copySelect REPLICATE('qwe',3)--REVERSE FlipSelect REVERSE(name) fromXueshengxinxi--SOUNDEX Returns a four-character code (SOUNDEX) that evaluates the similarity of two stringsSELECT SOUNDEX('Smith'),SOUNDEX('Smythe')--Space whitespace param
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.