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];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题