Home >Backend Development >PHP Tutorial >Usage of substr() and explode() functions in php
This article mainly introduces the usage analysis of substr() and explode() functions in PHP, and describes substr in detail in the form of examples. () and explode() function processing String skills are relatively frequently used functions in string operations and have certain practical value. Friends in need can refer to this article
The example describes the usage of substr() and explode() functions in PHP. Share it with everyone for your reference. The specific method is as follows: substr(The code is as follows:<?php echo substr("abcdef", 1, 3); // 返回 "bcd" echo substr("abcdef", -2); // 返回 "ef" echo substr("abcdef", -3, 1); // 返回 "d" echo substr("abcdef", 1, -1); // 返回 "bcde" ?>explode(separator,string,limit): This function splits the string into The code is as follows:
<?php $str = "abc|bck|fhq|nui"; print(explode("|",$srt)); //输出array([0]=>abc,[1]=>bck,[2]=>fhq,[3]=>nui) ?>
The above is the detailed content of Usage of substr() and explode() functions in php. For more information, please follow other related articles on the PHP Chinese website!