Php implementation code for deleting the first character in a string
Source: Internet
Author: User
The first word that appears in the delete string is the flexible use of explode. For more information, see
The code is as follows:
$ A = "string ";
$ C = explode ("text to be deleted", $ a, 2 );
$ B = $ c [0]. $ c [1];
Explode
(PHP 3, PHP 4, PHP 5)
Explode -- use one string to separate another string
Description
Array explode (string separator, string [, int limit])
This function returns an array composed of strings. each element is a substring of a string, which is separated by a string separator as a boundary point. If the limit parameter is set, the returned array contains up to limit elements, and the last element contains the rest of the string.
If separator is a null string (""), explode () returns FALSE. If the value of separator cannot be found in string, explode () returns an array containing a single string element.
If the limit parameter is negative, all elements except the last limit element are returned. This feature is added in PHP 5.1.0.
For historical reasons, although implode () can receive two parameter sequences, explode () cannot. You must ensure that the separator parameter is prior to the string parameter.
Note: The limit parameter is added to PHP 4.0.1.
Example 1. explode () example
The code is as follows:
// Example 1
$ Pizza = "piece1 piece2 piece3 piece4 piece5 piece6 ";
$ Pieces = explode ("", $ pizza );
Echo $ pieces [0]; // piece1
Echo $ pieces [1]; // piece2
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.