PHP Script: exploding strings into arrays when the strings have multiple character delimiters
This script is called exploding-strings-into-arrays-when-the-strings-have-multiple-character-delimiters.php
In searching the Internet, we found no evidence of a PHP script illustrating the use of multiple character delimiters when exploding PHP strings into arrays. The example at www.w3schools.com shows the use of spaces as single character delimiters to split a string into an array. No mention was made of the possibility of multiple character delimiters. So we wondered what the limits are. We tried a few experiments. The results seem to suggest that the PHP explode() function is not very fussy about what you use for a delimiter when you wish to explode strings into arrays.
In each of the three cases below, a nonstandard delimiter was used to get joe and harry into array elements. Copy it and try it out for yourself. In all three cases, joe goes into array element 0 and harry goes into array element 1.
This script is called exploding-strings-into-arrays-when-the-strings-have-multiple-character-delimiters.php
<?php
//exploding-strings-into-arrays-when-the-strings-have-multiple-character-delimiters.php
$people="joe<BR>harry";
$person = explode("<BR>", $people);
echo $person[0]."<BR>";
echo $person[1]."<BR><BR>";
echo "explode a string with a multiple character delimiter<BR><BR><BR>";
$people="joe!@#$%^&*()harry";
$person = explode("!@#$%^&*()", $people);
echo $person[0]."<BR>";
echo $person[1]."<BR><BR>";
echo "explode another string with a multiple character delimiter<BR><BR><BR>";
$people="joe went to town with a silly guy named harry";
$person = explode(" went to town with a silly guy named ", $people);
echo $person[0]."<BR>";
echo $person[1]."<BR><BR>";
echo "explode yet another string with a multiple character delimiter";
?>