PHP/String/String Split

Материал из Web эксперт
Перейти к: навигация, поиск

preg_split (/\+{1,}/)

<?php
   $delimitedText = "+Java+++PHP+++++++++++ASP+++OH";
   $fields = preg_split("/\+{1,}/", $delimitedText);
   foreach($fields as $field) echo $field."<br />";
?>



Splitting a String Based on a Found String

<html>
<head>
<title>preg_split</title>
</head>
<body>
<?php
     $date = "10/10.95";
   
     /* Allowed date delimiters are . / - */
     $date_array = preg_split("/[.\-\/]/", $date);
   
     var_dump($date_array);
?>
</body>
</html>