Php 从表单中获取标记并在数组中拆分它们的脚本

Php 从表单中获取标记并在数组中拆分它们的脚本,php,Php,我有一个functions.php页面,其中有一个简单的文本区域,如下所示: <tr valign="top"> <th scope="row">Tags:</th> <td><textarea name="tags" id="tags" cols="40" rows="6"><? echo get_option('tags'); ?></textarea></td> </tr> 我需要

我有一个functions.php页面,其中有一个简单的文本区域,如下所示:

<tr valign="top">
<th scope="row">Tags:</th>
<td><textarea name="tags" id="tags" cols="40" rows="6"><? echo get_option('tags'); ?></textarea></td>
</tr>
我需要一种拆分标签的方法。我试图按标签之间的间距分割标签(就像在preg split函数中一样),但是作为标签列表,一个标签下另一个标签下没有空格

有什么想法吗


Ty

在正则表达式中,空格用一个\s表示

$tags = get_option('tags');  // I pull all my submitted tags inside the $tags variable
if ($tags != ''){
    $tag = preg_split('/\s+/', $tags); // The problem is here
    $tag = array_map('trim', $tag);
}

在正则表达式中,空间用表示\s

$tags = get_option('tags');  // I pull all my submitted tags inside the $tags variable
if ($tags != ''){
    $tag = preg_split('/\s+/', $tags); // The problem is here
    $tag = array_map('trim', $tag);
}
将被任意数量的空格分割(例如换行符、制表符等)。我希望人们也使用逗号之类的,所以,你也可以决定拆分任何非字母字符


将被任意数量的空格分割(例如换行符、制表符等)。我希望人们也使用逗号等,因此,您也可以决定拆分任何非字母字符,例如。

您可以将其拆分为换行符:

explode("\n", $tags);

您可以将其拆分为换行符:

explode("\n", $tags);