php--string

Source: Internet
Author: User
Tags strcmp

<?PHP//strlen ("AAA"); Take the length of the string * * *    Echo strlen("AAAAA"); Echo"<br/>"; //$array = explode ("|", $s); splits the string, returns an array of strings * * *    $str 1= "Aaaa|bbb|cc|d"; $array 1=Explode("|",$str 1); Print_r($array 1); Echo"<br/>"; Print_r(Explode("|",$str 1)); Echo"<br/>"; //$s = substr ($s, 4,10), intercept string, intercept based on the end position of the start position * * *    $str 2= "Hello World"; Echo substr($str 2, 2,3); Echo"<br/>"; //strcmp ("AAA", "AAA"); compare two strings, same words output 0, different output-1//Case Sensitive    Echo strcmp("AAA", "BBB");//-1         Echo"<br/>"; Echo strcmp("AAA", "AAA");//0         Echo"<br/>"; //strcasecmp ("AAA", "AAA"); compare two strings, case insensitive    Echo strcasecmp("AA", "AA"); Echo"<br/>"; //strtolower ("abcdefgh"); Turn lowercase    Echo Strtolower("AAAAAABBBB"); Echo"<br/>"; //Strtoupper (); turn caps    Echo Strtoupper("AKJHAJKDHFJK"); Echo"<br/>"; //$s = implode ($array); converting an array to a string    Echo implode($array 1); Echo"<br/>"; //$s = substr_replace ($s, "China"); Replace string with position    $STR 3=Substr_replace($str 2, "Hello", 0,1); Echo $STR 3; Echo"<br/>"; //$s = str_replace ("L", "dog", $s); replacement string, equivalent to a lookup substitution in Notepad    $STR 4=Str_replace("L", "You Come Over",$STR 3); Echo $STR 4;?>

Notes

String processing:

strlen ("AAA"); Take the length of the string * * *
strcmp ("AAA", "AAA"); compare two strings, same words output 0, different output-1
STRCASECMP ("AAA", "AAA"); compare two strings, case insensitive
Strtolower ("abcdefgh"); turn lowercase
Strtoupper (); turn caps
$array = Explode ("|", $s); splits the string, returns an array of strings * * *
$s = implode ($array); converting an array to a string
$s = substr_replace ($s, "China"); Replace string with position
$s = Str_replace ("L", "dog", $s); replacement string, equivalent to a lookup substitution in Notepad
$s = substr ($s, 4,10), intercept string, intercept based on the end position of the start position * * *

php--string

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.