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