タグ付けシステムを作成したかったので、#tag などのハッシュされた単語を抽出してデータベースに挿入する方法を知りたいです。ありがとう
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 に答える