PHP Version
4+
/* Example of splitting strings into letters and numbers using a regular expression */
$string = 'Hello123';
$parts_string = preg_split('/(?<=\D)(?=\d)|(?<=\d)(?=\D)/', $string); // Splits letters and numbers
// The criteria for the specified regular expression pattern are the boundaries
// where a letter changes to a digit, or where a digit changes to a letter.

print_r($parts_string);
/* Output:
	Array (
		[0] => Hello
		[1] => 123
	)
*/
echo 'Letter: ' . $parts_string[0]; // Output: 'Letter: Hello'
echo 'Number: ' . $parts_string[1]; // Output: 'Number: 123'

/* Simple example of extracting the protocol from a URL */
$url = "https://www.example.com/path/to/resource";
$parts_url = preg_split('#://#', $url);
print_r($parts_url);
/* Output:
	Array (
		[0] => https
		[1] => www.example.com/path/to/resource
	)
*/

echo 'Protocol type: ' . $parts_url[0]; // Output: 'Protocol type: https'
preg_split(
    string $pattern,
    string $subject,
    int $limit = -1,
    int $flags = 0
): array|false

/* preg_split(
	The regular expression pattern,
	The subject string to be split[,
	The maximum number of substrings to be returned[,
	The flags specifying additional settings]]
);
*/
$str = 'This,is,a,,string';

/* Splits the given string by a comma (,) and includes empty strings in the result. */
$parts = preg_split('/,/', $str);
print_r($parts);
/* Output:
    Array (
        [0] => This
        [1] => is
        [2] => a
        [3] =>
        [4] => string
    )
*/

/* Splits the given string by a comma (,) and excludes empty strings from the result. */
$no_empty_parts = preg_split('/,/', $str, -1, PREG_SPLIT_NO_EMPTY);
print_r($no_empty_parts);
/* Output:
    Array (
        [0] => This
        [1] => is
        [2] => a
        [3] => string
    )
*/
$str = 'This,is,a,,string';

// Using the PREG_SPLIT_DELIM_CAPTURE flag
$str = 'This,is,a,,string';

/* Splits the given string by a comma (,) and includes the comma (,) in the result. */
$with_comma_parts = preg_split('/(,)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($with_comma_parts);
/* Output:
    Array (
        [0] => This
        [1] => ,
        [2] => is
        [3] => ,
        [4] => a
        [5] => ,
        [6] =>
        [7] => ,
        [8] => string
    )
*/
// Using the PREG_SPLIT_OFFSET_CAPTURE flag
$str = 'This,is,a,,string';

/* Splits the given string by a comma (,) and
   each element in the result array consists of a (string, start position) pair. */
$with_offset_parts = preg_split('/,/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
print_r($with_offset_parts);
/* Output:
	Array (
		[0] => Array (
			[0] => This
			[1] => 0
		)
		[1] => Array (
			[0] => is
			[1] => 5
		)
		[2] => Array (
			[0] => a
			[1] => 8
		)
		[3] => Array (
			[0] =>
			[1] => 10
		)
		[4] => Array (
			[0] => string
			[1] => 11
		)
	)
*/
$csv_data = "John,Doe,25\nJane,Smith,30\n";
$lines = preg_split('/\n/', $csv_data, -1, PREG_SPLIT_NO_EMPTY);
$csv_array = [];

foreach ($lines as $line) {
    $csv_array[] = preg_split('/,/', $line, -1, PREG_SPLIT_NO_EMPTY);
}

print_r($csv_array);
/* Output:
    Array (
        [0] => Array (
            [0] => John
            [1] => Doe
            [2] => 25
        )
        [1] => Array (
            [0] => Jane
            [1] => Smith
            [2] => 30
        )
    )
*/
$url = 'https://www.example.com/path/to/resource';
$url_parts = preg_split('#://|/#', $url, -1, PREG_SPLIT_NO_EMPTY);

print_r($url_parts);
/* Output:
	Array (
		[0] => https
		[1] => www.example.com
		[2] => path
		[3] => to
		[4] => resource
	)
*/
$url = 'https://www.example.com/path/to/resource?query=string&foo=bar';

// Return the URL separated into its components
$url_components = parse_url($url);

// Output the result
print_r($url_components);
/* Output:
	Array (
		[scheme] => https
		[host] => www.example.com
		[path] => /path/to/resource
		[query] => query=string&foo=bar
	)
*/