PHP string manipulation function Exercise 2

Source: Internet
Author: User
Tags ord strcmp strtok

<?PHPHeader("Content-type:text/html;charset=utf-8");/**1,ord () returns the ASCII value of the first character of the string 2,strcasecmp () a case-insensitive comparison of two strings 3,strcmp () case-sensitive comparisons between two strings 4,strncmp () case-sensitive compared to a string of first n characters of 5, STRNCASECMP () is case-insensitive compared to the first n characters of a string 6,strnatcmp () strnatcasecmp case-insensitive, case-insensitive comparisons of string lengths in natural order 7,chunk_split () splits a string into small chunks 8, Strtok () Cut string 9,explode () converts a string to an array based on a specified character 10,implode () convert a one-dimensional array to a bit string */Echo Ord("Hello Man"). " <br> ";//returns a letter of the ASCLL codeEcho strcasecmp("Hello man", "Hello Man"). " <br> ";//A case -insensitive comparison of two lettersif(!strcasecmp("Hello man", "Hello Man")) {//same words return 0, not the same words return-1Echo"The contents of the two strings are the same." <br> ";}Else{Echo"Not the same!" "." <br> ";}Echo strcmp("Hello man", "Hello Man"). " <br> ";//This is case-sensitive.Echo strnatcasecmp("Hello man", "Hello Man"). " <br> ";//compares the length of two strings before the large return is 1 otherwise it is -1Echo strncmp("I Love china!", "I Love shanghai!", 6). " <br> ";//compares the first n characters of a string to a case-sensitiveEcho strlen("He Llo"). " <br> ";//in PHP, the space of a string is the length of a byte that takes upEcho Chunk_split("Hello Man", 1, "!"). " <br> ";//The length of every other byte is in the back plus one! $string= "Hello World". Beautiful Day today. ";$token=strtok($string, " ");//Cut the = string to a custom symbol, where the $taken= "Hello" while($token!==false)//loop output, which returns a string with a flag position{Echo"$token<br> ";$token=strtok(" ");}Echo"<br>";$str 1= "Hello:man:Eminem";$s=Explode(‘:‘,$str 1);//output is an array of threePrint_r($s);Echo"<br>";Echo implode($s,".");//the output is a string

PHP string manipulation function Exercise 2

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.