如何通过空格将字符串分解为数组,但保留引用的单词?

时间:2015-07-08 20:42:23

标签: php regex parsing explode

给定字符串abc "def ghi",我该如何返回数组:

[0] => abc
[1] => def ghi

其他例子:

abc "def ghi"   =>   ['abc','def ghi']
abc def         =>   ['abc','def']

2 个答案:

答案 0 :(得分:2)

str_getcsv()

select $DB::OUT

返回:

$str = 'abc "def ghi"';
$arr = str_getcsv($str, ' ', '"');
print_r($arr);

答案 1 :(得分:0)

您可以使用:

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
    {
        if (e.Node == tv.SelectedNode)
            treeView1_AfterSelect(sender, null);
    }