<?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