Rob Gudgeon wrote:
Is it possible to explode a string into an array using more than one
separator? I have database records that contain several values,
mostly split by semi-colons but some older records are split by comma.
It's obviously no hassle if I have to explode twice but it'd be nice
if I could do it with one line...
You use "split" instead of "explode" for that (with regular
expressions).
The following is a PHP.net example splitting on "/", ".", and "-"
(unfortunately only in German in my browser, so here's some
translation):
<?
$myDate = "2003/12/12";
list ($myMonth, $myDay, $myYear) = split ('[/.-]', $myDate);
echo "Month: $myMonth; Day: $myDay; Year: $myYear<br />\n";
?>