Several commonly used PHP string functions

Source: Internet
Author: User
Tags rtrim

<?PHP$a= "@[email protected]"; $trim=Trim($a,‘@‘);//Remove the @//var_dump ($trim) on the left and right side;    $ltrim=LTrim($a,‘@‘);//Remove the @//var_dump ($ltrim) on the left;    $rtrim=RTrim($a,‘@‘);//Remove the @//var_dump ($rtrim) on the right;    $strlen=strlen($a);//the length of the statistic string//var_dump ($strlen);    $strrev=Strrev($a);//Invert string//var_dump ($strrev);    $str _shuffle=Str_shuffle($a);//randomly scrambled string//var_dump ($str _shuffle);    $explode=Explode(' A ',$a);//a split string is an array of//var_dump ($explode);    $implode=implode(' A ',$explode);//put $explode this array using a stitching for string//var_dump ($implode);    $str _replace=Str_replace(' A ', ' B ',$a);//string substitution replaces a in a $ A string with B//var_dump ($str _replace);    $strpos=Strpos($a, ' Q ');//find the position where Q first appeared in $ A//var_dump ($strpos);    $strrpos=Strrpos($a, ' Q ');//find the last position of Q in $ A//var_dump ($strrpos);    $b= ' I love You '; $strtoupper=Strtoupper($b);//the string is converted to uppercase//var_dump ($strtoupper);    $c= ' I Love You '; $strtolower=Strtolower($c);//the string is converted to lowercase//var_dump ($strtolower);    $ucwords=Ucwords($b);//the first letter of each word in the string is capitalized//var_dump ($ucwords);    $ucfirst=Ucfirst($b);//write//var_dump of the first letter of the string ($ucfirst);    $substr=substr($a, '-1 ');//string interception starts from the countdown to the first intercept of//var_dump ($SUBSTR);    $strstr=strstr($a, ' Q ');//finds the position where Q first appears in the string $ A and returns the position to the end of the string//var_dump ($STRSTR);    $STRRCHR=STRRCHR($a, ' Q ');//Find Q Returns the string from this position to the end at the last occurrence of the string//var_dump ($STRRCHR);    $str _repeat=str_repeat($a, ' 2 ');//repeat $ A of this string 2 times after the result//var_dump ($str _repeat);?>

Several commonly used PHP string functions

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.