tags:

views:

34

answers:

1

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

+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
good answer, thank you, made my life much easier
getaway
no problem, glad i could help!
joshtronic