i wanted to create a tagging system, so i want to know how can i extract the hashed words i.e #tag and then insert them into the database, can you lead me to a toturial or help out! thanks
views:
34answers:
1
+3
A:
<?php
$string = 'this is a #string with #hash tags #yessir';
preg_match_all('/#([a-z0-9-_]+)/', $string, $matches);
print_r($matches);
// Do your database stuff here...
?>
Which will give you:
Array
(
[0] => Array
(
[0] => #string
[1] => #hash
[2] => #yessir
)
[1] => Array
(
[0] => string
[1] => hash
[2] => yessir
)
)
joshtronic
2010-08-29 20:59:26
good answer, thank you, made my life much easier
getaway
2010-08-29 22:20:48
no problem, glad i could help!
joshtronic
2010-08-30 00:12:16