Skip to content

Instantly share code, notes, and snippets.

@pascalchevrel
Created May 30, 2013 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalchevrel/5678063 to your computer and use it in GitHub Desktop.
Save pascalchevrel/5678063 to your computer and use it in GitHub Desktop.
<?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