How to split a word or sentence delimited with slashes, commas or hyphens

Last updated on July 29th, 2009 at 03:11 am

Click to rate this tutorial!
[Total: 4 Average: 4.3]

How to split a word or sentence delimited with slashes,commas, dots, or hyphens

< ?php
// Delimiters may be slash, comma, or hyphen
$data = “Welcome to, the world of php”;
list($first, $second) = split(‘[/,-]’, $data);
echo “First Letter: $first; Second Splitted letter: $second
\n”;
?>

Click to rate this tutorial!
[Total: 4 Average: 4.3]

Leave a Reply

Your email address will not be published.