Split string into array using explode function in php_PHP tutorial

WBOY
Release: 2016-07-13 10:39:33
Original
834 people have browsed it

Split the string

//Use the explode function to split the string into an array

Copy the code The code is as follows:

$source = "hello1,hello2,hello3,hello4,hello5";//Separate strings by commas
$hello = explode(',',$source);

for($index=0;$index{
echo $hello[$index];echo "
";
}
?>

//split function performs character splitting
// The separator can be a slash, dot, or horizontal line
Copy the code The code is as follows:

$date = "04/30/1973";
list($month, $day, $ year) = split ('[/.-]', $date);
echo "Month: $month; Day: $day; Year: $year
n";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/730055.htmlTechArticleSplit the string//Use the explode function to split the string into an array. Copy the code as follows: ?php $source = " hello1,hello2,hello3,hello4,hello5";//Separate strings by commas $hello = ex...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!