PHP Common String processing

Source: Internet
Author: User

<?php/** * Created by Phpstorm. * User:tang * date:14-11-16 * Time: 2:19 *///The string to the array.    $string = "fafa.afaf.fsfs.342.4fw3.x"; $arr = Explode ('. ', $string); In points, convert to a group. Var_dump ($arr);      $count = count ($arr); Var_dump ($count); Count () This is a function of the system that calculates the number of.  $art = $arr [$conut-1]; View the value of the last cell in the array. Var_dump ($art);   Turn the array into a string $arr = Array (1,3,4, ' d ', ' d ', ' 4d '), Echo implode (', ', $arr), ' <br/> '; Adds the value of the array to a string of characters. Press ', ' to mark.   Intercept $string = "ABCDEFG"; Echo substr ($string, -3,1), ' <br/> '; function internal parameter The first argument, which represents the starting point, positive number is from the string left to right, negative numbers are the tail to the left. The second parameter, represents, several. Note the number of strings, starting with 0 bits.    Replace $string = ' fafa.fafda.eiakf.3ad.4d '; Echo str_replace ('. ', ' * ', $string);    The first parameter of the function () is the tag, the second argument, the target to replace, and the third argument is the variable//repeat output of the corresponding string $str = ' abc '; echo str_repeat ($str, 10); function () The first argument, which corresponds to a repeating string variable. The second parameter is the number of repetitions.

PHP Common String processing

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.