Created
May 30, 2013 14:03
-
-
Save pascalchevrel/5678063 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Utils; | |
class Strings | |
{ | |
public static function substringsCount($string, $dots) | |
{ | |
str_replace($dots, '#\#\#', strip_tags($string), $val); | |
return $val; | |
} | |
public static function substrings($string, $dots) | |
{ | |
$string = strip_tags($string); | |
foreach($dots as $dot) { | |
$string = str_replace($dot, $dot . '#\#\#', $string); | |
} | |
$string = explode('#\#\#', $string); | |
$string = array_filter($string); | |
$string = array_map('trim', $string); | |
return $string; | |
} | |
$str = "Also new in this release: Google is now your default search engine. To change the active search engine, click the down arrow next to the search engine's icon, and select a new search engine."; | |
$dots = array('.', '!', '?', ';', ':', '...'); | |
echo $str . '<br>'; | |
echo Strings::substringsCount($str, $dots); | |
var_dump(Strings::substrings($str, $dots)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment