-----014-string.php-----
1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title> a PHP page </title>67<body>8<pre>9<?PHPTen Echo"; One $str 1= "Hello"; A $str 2= "HELLO"; - printf("%s than%s:%d\n",$str 1,$str 2,strcmp($str 1,$str 2)); - printf("%s is not case-sensitive than%s:%d\n",$str 1,$str 2,strcasecmp($str 1,$str 2)); the $str 1= "Helwww"; - $str 2= "HELQQQ"; - printf("%s than%s, first three characters:%d\n",$str 1,$str 2,strncmp($str 1,$str 2, 3)); - printf("%s is greater than%s, first three characters, case-insensitive:%d\n",$str 1,$str 2,strncasecmp($str 1,$str 2, 3)); +?> -<?PHP + Echo"; A $str= "Hoist"; at $result=Str_replace("Gourd", "Gourd Doll",$str,$count); - printf(Gourd, gourd, gourd):%s. %d \ n "was replaced,$result,$count); - $result=Substr_replace($str, "Gourd Doll", 3, 3);//UTF-8 - printf("2+2-> gourd"):%s. \ n ",$result); -?> -<?PHP in Echo"; - $str= "Plants vs Big Zombies"; to printf("Plants vs big zombies, from the big start:%s\n",STRCHR($str, "Big")); + printf("Plants vs big zombies, from the big start, take the left half:%s\n",STRCHR($str, "Big",true)); - printf("Plants vs big zombies, big position:%d\n",Strpos($str, "Big", 0)); the printf("Plants vs big zombies, big position: Starting with the third word%d\n",Strpos($str, "Big", 9)); * printf("Plants vs big zombies, from the big start on the right:%s\n",STRRCHR($str, "Big")); $ printf("Plants vs big Zombies, starting with the second character:%s\n",substr($str, 3));Panax Notoginseng printf("Plants vs big zombies, big occurrences:%s\n",Substr_count($str, "Big")); -?> the<?PHP + Echo"; A $str= "Plants vs. Zombies"; the $s=strtok($str, " "); + while($s) { - Echo $s, "\ n"; $ $s=strtok(" "); $ } - foreach(Explode(" ",$str) as $temp){ - Echo $temp, "\ T"; the } - Echo implode("+",Array("Plants", "war", "zombies")));Wuyi?> the<?PHP - Echo"; Wu Echo Strtolower("PHP"), "\ n"; - Echo Strtoupper("Java"), "\ n"; About Echo Ucfirst("What do you see are?"), "\ n"; $ Echo Ucwords("What do you see are?"), "\ n"; - foreach(Count_chars("abbcccdddd", 1) as $key=$value){ - Echo $key, "= =",$value, "\ n"; - } A?> +<?PHP the Echo"; - $arr=Array("Conan", "Pirate King", "Naruto", "Cherry Ball"); $ foreach($arr as $value) { the Echo Str_pad($value, 18, "-",str_pad_left); the Echo"\ n"; the } the?> -<?PHP in Echo"; the $str= "* * Drip power * *"; the Echo"Pending string: |",$str, "|\n"; About Echo"Exclude Spaces |",Trim($str), "|\n"; the Echo"Reject Asterisk |",Trim($str, "*"), "|\n"; the Echo"Reject asterisk space |",Trim($str, "*"), "|\n"; the Echo"Left Reject asterisk space |",LTrim($str, "*"), "|\n"; + Echo"Right Reject asterisk space |",RTrim($str, "*"), "|\n"; -?> the</pre>Bayi</body> the