douxitao8170 2013-01-14 14:58
浏览 60
已采纳

PHP Preg_Match从字符串中提取逗号分隔值[重复]

Possible Duplicate:
PHP preg_match_all: Extract comma seperated list

I have a string that looks like: [something ="1,2,3"] I need get everything between the quotes into a string. I'm sure that preg_match is the way to do this but i'm not sure of the expression to use.

$content = [something = "1,2,3"];
$new_string = preg_match('?regex?','$content');
  • 写回答

1条回答 默认 最新

  • dpvomqeu396484 2013-01-14 15:00
    关注

    Try this:

    $content = '[something = "1,2,3"]';
    
    if (preg_match('/"([^"]+)"/', $content, $matches)) {
        $matchedContent = $matches[1];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?