I ve devised a tagging system for my Website where tags beginning with a hash (#) function differently to those without. I m trying to extract all hash tags from my database and load them into an array:
$keywords = mysql_query("SELECT Keywords FROM Tags WHERE Keywords LIKE #% ") or die("Query failed with error: ".mysql_error());
$stack = array();
while ($row = mysql_fetch_array($keywords))
{
$wrds = $row[ Keywords ];
$val = preg_match("/#w+(?=,|)/", $wrds, $matched);
while (!empty($matched))
{
$val = array_pop($matched);
if (array_search($val, $stack) === FALSE)
{
array_push($stack, $val);
}
}
}
5. MySQL询问如下:
+------------------------+
| Keywords |
+------------------------+
| #test1, test |
| #test1, #test2, #test4 |
| #test3, #est5 |
| #test3 |
+------------------------+
我想像以下几个方面:
Array(
[0] => #test1
[1] => #test2
[2] => #test4
[3] => #test3
[4] => #est5
)
我做了什么错误?