-2

重複の可能性:
PHP preg_match_all:コンマ区切りリストを抽出

次のような文字列が[something ="1,2,3"] あります。引用符の間のすべてを文字列にまとめる必要があります。preg_matchがこれを行う方法であると確信していますが、使用する式がわかりません。

$content = [something = "1,2,3"];
$new_string = preg_match('?regex?','$content');
4

1 に答える 1

1

これを試して:

$content = '[something = "1,2,3"]';

if (preg_match('/"([^"]+)"/', $content, $matches)) {
    $matchedContent = $matches[1];
}
于 2013-01-14T15:00:53.347 に答える