Repeated items in one-dimensional array:
Use the array_unique function. Use the following example:Copy codeThe Code is as follows:$ Aa = array ("apple", "banana", "pear", "apple", "wail", "watermalon ");$ Bb = array_unique ($ aa );Print_r ($ bb
UTF-8 matching: In javascript, it is very easy to judge that the string is Chinese. For example:Copy codeThe Code is as follows:Var str = "php programming ";If (/^ [\ u4e00-\ u9fa5] + $/. test (str )){Alert ("all strings are Chinese ");} Else {Alert
Copy codeThe Code is as follows:Define (CHARSET, 'utf-8'); // default system Encoding/*** Trim strings based on Chinese Characters* @ Param $ string-string* @ Param $ length-length* @ Param $ doc-thumbnail suffix* @ Return returns the string with
Content of this section:Specify the default value for the php function.In php programming, set the default value for the custom function. When you call this function, if you do not specify a value for the parameter, the parameter will be replaced by
Copy codeThe Code is as follows:/*** Get_redirect_url ()* Gets the address that the provided URL redirects,* Or FALSE if there's no redirect.** @ Param string $ url* @ Return string*/Function get_redirect_url ($ url ){$ Redirect_url = null;$
Copy codeThe Code is as follows:/*** The Images class is an image processing class.* @ Package application. controllers* @ Since 1.0*/Class Images{ /*** Scale an image* @ Param $ source Original Image* @ Param $ newfile New Image* @ Param $ pre zoom
Text watermark
A text watermark adds text to an image. It mainly uses the imagefttext method of the gd library and requires a font file. As follows:
The implementation code is as follows:
Copy codeThe Code is as follows:$ Dst_path = 'dst.jpg ';
//
To obtain the size of a remote image, a common practice is to first retrieve the content of the remote image and use strlen to calculate the length. In this way, you need to download the image before calculating it. If the image size is large,
GBK encoding truncation example
Copy codeThe Code is as follows:$ Str = 'Who Am I '; // A gbk-encoded stringEcho mb_substr ($ str, 0, 1, 'gbk'); // output me
The mb_substr method has one more parameter than the substr method to specify string
[Page] $ _ SERVER ['php _ SELF '] # File Name of the script being executed, which is related to document root.$ _ SERVER ['argv'] # parameters passed to the script.$ _ SERVER ['argc '] # contains the number of command line parameters passed to the
During the previous work, I encountered a PHP function: set_time_limit (). I thought this was a very simple function, but Baidu has published several articles and found that there are still many aspects worth attention when using this function.
When developing PHP programs, we sometimes write the same code at the beginning and end of each PHP script. For example, we often need to open and close sessions on every PHP page or establish and close database connections. Good programmers usually
A simple php mongodb operation class only writes a php query operation for the mongodb database. for other operations, see http://blog.php230.com/php-mongodb-database-operation.html.
A simple php mongodb operation class, only write a php query
Php Chinese string truncation} the above method can be used to prevent garbled characters.
Php Chinese string truncation
Code:
/*** String truncation * @ param $ string the string to be intercepted * @ param $ length the length of the int
A tree-based parser. It stores the entire document in the data structure of the tree, that is, it must be loaded into the memory to work. Therefore, when processing large XML documents, the performance decreases dramatically. SimpleXML and DOM
The above section describes how to use php to export excel files. here is how to import excel files through php.
The above section describes how to use php to export an excel file. here we will share the method of importing an excel file through
Php obtains the mac address of the local machine.
How to obtain the mac address of a local machine using php
Code:
Forlinux (); break; case "solaris": break; case "unix": break; case "aix": break; default: $ this-> forwindows (); break ;} $
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service