-1

我想创建一个标记系统,所以我想知道如何提取散列词,即#tag,然后将它们插入数据库,你能带我去看看或帮忙吗!谢谢

4

1 回答 1

3
<?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...

?>

这会给你:

Array
(
    [0] => Array
        (
            [0] => #string
            [1] => #hash
            [2] => #yessir
        )

    [1] => Array
        (
            [0] => string
            [1] => hash
            [2] => yessir
        )

)
于 2010-08-29T20:59:26.593 回答