1// Example 1
2$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
3$pieces = explode(" ", $pizza);
4echo $pieces[0]; // piece1
5echo $pieces[1]; // piece2
1<?php
2// It doesnt get any better than this Example
3$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
4$pieces = explode(" ", $pizza);
5echo $pieces[0]; // piece1
6echo $pieces[1]; // piece2
1// split() function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0.
2// ALTERNATIVES: explode(), preg_split()
3
4// explode()
5// DESCRIPTION: Breaks a string into an array.
6// explode ( string $separator , string $string , int $limit = PHP_INT_MAX ) : array
7$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
8$pieces = explode(" ", $pizza);
9echo $pieces[0]; // piece1
10echo $pieces[1]; // piece2
11
12// preg_split()
13// DESCRIPTION: Split the given string by a regular expression.
14// preg_split ( string $pattern , string $subject , int $limit = -1 , int $flags = 0 ) : array|false
15$keywords = preg_split("/[\s,]+/", "hypertext language, programming");
16print_r($keywords);
17// output:
18Array
19(
20 [0] => hypertext
21 [1] => language
22 [2] => programming
23)
1
2<?php
3// Beispiel 1
4$pizza = "Teil1 Teil2 Teil3 Teil4 Teil5 Teil6";
5$teile = explode(" ", $pizza);
6echo $teile[0]; // Teil1
7echo $teile[1]; // Teil2
8
9// Beispiel 2
10$data = "foo:*:1023:1000::/home/foo:/bin/sh";
11list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
12echo $user; // foo
13echo $pass; // *
14
15?>
16
17