我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何在与preg_match匹配后获取变量值

This is my code:

$str = "nbvmxnbvn Shopify.shop=gfkhfhkd";
preg_match('/Shopify.shop=/', $str, $matches);
print_r($matches);

I'm getting the output after print_r as Shopify.shop= but I want gfkhfhkd as the output.

Modify your regex slightly so that it can capture the proper substring you're looking for.

preg_match('/Shopify.shop=(.*)/',$str,$matches);
echo $matches[1];   //gfkhfhkd

Fiddle

$matches = preg_grep('/Shopify.shop=(.*)/', $str);
print_r ($matches);

近期文章

  • Laravel确定何时更新字段
  • 如何向每个用户显示自定义数量的SVG圈子?
  • 将表列转换为另一个表
  • 调用函数来终止php脚本
  • $ http调用后,带有angularJS加载模板的Laravel
  • 设置家庭自动化的远程控制面板页面[关闭]
  • GuzzleHttp Stream对象为utf-8编码的HTML?
  • 将命令放在后台并通过PHP exec()获取PID?
  • 使用PHP和MYSQLI无法使OOP寄存器形式工作
  • LinkedIn REST API - 公司分享| 使用JSON或XML,都失败了
  • Symfony Super Roles无法访问Base Roles
  • 将PHP数组插入MYSQL
  • 复选框没有得到正确的顺序
  • 使用php更改数据库中的数据
  • 在类中设置一个变量以用于多个函数/方法
  • Laravel Eloquent模型ManyToMany让所有用户都有自己的角色
  • 使用ajax和PHP提交已编辑表单的问题
  • Wordpress ajax非常慢,无法检索发布数据
  • WordPress - add_filter函数和字符串参数?
  • while循环在第一个循环停止,因为mysqli错误

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华