Created
October 21, 2017 23:08
-
-
Save lenivene/90a406aa41a84810a27cced0f5128424 to your computer and use it in GitHub Desktop.
Get hash tag with php
This file contains hidden or 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 | |
/* | |
* First array return "tags" with hash, example: #Example | |
* Second "tag" return without hash, Example: Example | |
* | |
* @string $tweet The text | |
* @function preg_match_all | Pattern | @string $tweet (The text) | @array $tags (output array the tags) | |
* @return array $tags | |
*/ | |
$twet = "But I must #explain to u how all this #mistaken idea of #denouncing pleasure and praising pain was born and I'll #give you a complete accout"; | |
preg_match_all( "/#([\p{Pc}\p{N}\p{L}\p{Mn}]+)/u", $tweet, $tags ); | |
echo "<pre>"; | |
var_dump( $tags ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment