我在DB中有超过2个lac记录,如下所示:[u'jazz', u' female vocalists', u' vocal jazz', u' jazz vocal']
我需要通过PHP解析每条记录。
例如,
$tags="[u'jazz', u' female vocalists', u' vocal jazz', u' jazz vocal']";
我需要解析4个单独的小标签,如:
答案 0 :(得分:2)
<?php
$tag="[u'jazz', u' female vocalists', u' vocal jazz', u' jazz vocal']";
preg_match_all("~'(?:\s?([^']+))'~",$tag,$matches);
print_r($matches[1]);
输出
Array
(
[0] => jazz
[1] => female vocalists
[2] => vocal jazz
[3] => jazz vocal
)