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

从字符串中获取两个特定文本

$string = "Anda mendapatkan penambahan pulsa Rp 100000 dari nomor 6282298981111 tgl 2018-07-08. Cek pulsa melalui *888#. Info CS: 188";

I want to get text 100000 and 6282298981111 how is the code?

Thanks in advance, I'm new in here

You can use the following regular expression:

preg_match_all('~(?<=\s)\d+(?=\s)~', $string, $matches);
print_r($matches[0]);

At the output, get

Array
(
    [0] => 100000
    [1] => 6282298981111
)

近期文章

  • 在Laravel中更改静态Eloquent属性
  • 在mysql查询中无法避免重复的结果
  • 预加载要为Gallery中每个项目设置为CSS背景图像的高质量背景图像
  • 如何将自定义wysiwyg编辑器实现到网站[关闭]
  • PHP soap服务调用.Net webservice
  • php session_start()忽略已创建的会话
  • 如何在PHP类中使用Amazon SES
  • wordpress中关键字和年份的具体搜索代码是什么?
  • 拍卖网站的PHP / jquery倒计时器
  • 登录时更新用户表而不触及供应商文件夹laravel 5.1
  • 使用m-d-Y格式时,如何找到2个日期(以天为单位)的差异?
  • 将Facebox添加到FullCalendar事件
  • CakePHP 3.x多文件上传无法正常工作
  • PHAR - 使用cwd而不是sys_temp_dir
  • preg_match不在特定标签之间
  • 使用PHP问题执行Bash脚本
  • 检查对象是否具有php / laravel中的值
  • Firebase index.php
  • Android PHP Mysql通过params获取数据
  • 当我选择数据1周时,PHP PDO无法使用select

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华