2010-08-29 61 views

回答

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 
     ) 

) 
+0

很好的答案,謝謝你,讓我的生活變得更輕鬆 – getaway 2010-08-29 22:20:48

+0

沒問題,很高興我能幫助! – joshtronic 2010-08-30 00:12:16

相關問題