PHP 子字符串问题 [英] A PHP substring issue

查看:29
本文介绍了PHP 子字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个简单的 php 问题,就是我不知道如何在这里使用子字符串...

I got a simple php issue which is that I don't know how to use substring here...

ABCDEF[RAND NUMBER 1-10000000]GH

所以我需要使用子字符串获取该随机数,

And so I need to get that random number using substring,

我不知道我今天的大脑是否正常工作,但我真的不知道该怎么做.

I dont know if my brain works correctly today but I really couldnt figure how to do that.

推荐答案

Regex 在这种情况下总是更好,但是如果你的字符串模式像 ABCDEF123456GH 一样固定,你可以简单地使用 substr like

Regex is always better in this case but If your string pattern is fixed like ABCDEF123456GH, you can simply use substr like

$str = "ABCDEF432465GH";
echo substr($str, 6, -2);

这篇关于PHP 子字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆