Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. /**
  2. * conver string to hastag
  3. * @param string $string string you want to convert
  4. * @param boolean $with_hashtag if false, it won't return the # sign
  5. * @return string Eureka! you got your #hashtag!
  6. */
  7. function stringToHashtag($string, $with_hashtag = true)
  8. {
  9. $_string = str_replace(' ', '', $string);
  10. $_out = preg_replace('/[^a-zA-Z]/', '', strtolower($_string));
  11. return ($with_hashtag) ? "#". $_out : $_out ;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement