微信 - php+mysql问题.怎么判断一个字符串符合数据表中的哪条正则表达式值得数据?
Question 2. 如何判断一个字符串符合数据表中的哪条规则?
微信公众平台开发,
以课表开头 ,即 ^课表 由function1处理(当然这是设置在数据库中,现在举例将其固定化),
以 2015开头,即^2015 由function2处理,
完全等于报名
,即^报名$ 由 function3处理。
在数据表中就是
rule | function | priority(优先级) |
---|---|---|
^课表 | function1 | 1 |
^2015 | function2 | 1 |
^报名$ | function3 | 1 |
…… | …… | …… |
如何拿到值判断其对应哪一条呢(假设不考虑优先级问题)?
Question 1. 如何判断一个数值在数据表的一条范围中
会员表,
ID,USERNAME,PASSWORD,TRUENAME,AVATAR,SCORE,BALANCE,ADD_TIME,REGIP
等级表,
0-100是 level1
101-500 level2
501-1500 level3
现在获取到用户的积分了,比如说是299.如何判断其是level2呢?
循环的确实是可以。但是效率不高。而且这是由用户设置的不固定。
回复内容:
Question 2. 如何判断一个字符串符合数据表中的哪条规则?
微信公众平台开发,
以课表开头 ,即 ^课表 由function1处理(当然这是设置在数据库中,现在举例将其固定化),
以 2015开头,即^2015 由function2处理,
完全等于报名
,即^报名$ 由 function3处理。
在数据表中就是
rule | function | priority(优先级) |
---|---|---|
^课表 | function1 | 1 |
^2015 | function2 | 1 |
^报名$ | function3 | 1 |
…… | …… | …… |
如何拿到值判断其对应哪一条呢(假设不考虑优先级问题)?
Question 1. 如何判断一个数值在数据表的一条范围中
会员表,
ID,USERNAME,PASSWORD,TRUENAME,AVATAR,SCORE,BALANCE,ADD_TIME,REGIP
等级表,
0-100是 level1
101-500 level2
501-1500 level3
现在获取到用户的积分了,比如说是299.如何判断其是level2呢?
循环的确实是可以。但是效率不高。而且这是由用户设置的不固定。
你两个问题,可不可以换位思考一下,举例来说,问题一
0-100是 level1
101-500 level2
501-1500 level3
你在会员表里面记录用户的积分字段,299就是一个数值,然后你对这些等级,做一个配置文件,这个可以是你定义或者交给用户去定义生成的配置文件,符合某个数值断的,就是哪个等级,不需要额外的判断
Q1 可以做个常量数组或者通过后台配置一个config文件,每次取到信息后去数组里取一下level就好了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

The top ten digital virtual currency trading apps in 2025 are as follows: 1. OKX, 2. Binance, 3. Gate.io, 4. Bybit, 5. Kraken, 6. KuCoin, 7. Bitget, 8. HTX, 9. MEXC, 10. Coinbase. This ranking is based on comprehensive evaluations such as security, liquidity, user experience and feature richness.

The top ten virtual currency trading apps in 2025 are as follows: 1. OKX, 2. Binance, 3. Gate.io, 4. Bybit, 5. Kraken, 6. KuCoin, 7. Bitget, 8. HTX, 9. MEXC, 10. Coinbase. This ranking is based on comprehensive evaluations such as security, liquidity, user experience and feature richness.

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

Detailed explanation of the problem of deducting balances in combination with PHP optimistic locks and transactions in this article will analyze in detail a balance deduction using PHP, optimistic locks and database transactions, only...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Compatibility issues and troubleshooting methods for company security software and application. Many companies will install security software in order to ensure intranet security. However, security software sometimes...

How to share the same page on the PC and mobile side and handle cache issues? In the nginx php mysql environment built using the Baota background, how to make the PC side and...
