There are two arrays: {code ...} here, @ is any possible string. Now let me get a string {code ...} how can I determine the array in which the $ message belongs? There are two arrays:
$ Template1 = array ("Hello, your website is @, please visit", "your reservation time is @. please report on time ", "your interview is over. please give @ a comment. visit @") $ template2 = array ("your verification code is @", "all special characters include @")
@ Is any possible string. Now let me get a string
$ Message = "Hello, your website is http://www.baidu.com/jsdkj. please visit ";
Determine this$messageWhich array does it belong to? how can this problem be determined?
Reply content:
There are two arrays:
$ Template1 = array ("Hello, your website is @, please visit", "your reservation time is @. please report on time ", "your interview is over. please give @ a comment. visit @") $ template2 = array ("your verification code is @", "all special characters include @")
@ Is any possible string. Now let me get a string
$ Message = "Hello, your website is http://www.baidu.com/jsdkj. please visit ";
Determine this$messageWhich array does it belong to? how can this problem be determined?
Convert the string in the template into a regular expression and match the message one by one.
For example:
$ Template1 = array ("Hello, your website is. *, please visit "," your reservation time is in. *, please arrive on time. * report "," your interview is over. please give it. * comment. The url is in. *")
It is worth noting that if the template array is large, performance may be affected. In addition, template rendering is usually unidirectional, so I am skeptical about the rationality of this requirement.
Onein_arrayCan this be done? Is it because I have misunderstood the meaning of the landlord?
Just judge strpos in the form of a keyword.
This logic is too rare. Generally, the message is obtained based on the variable + template and does not need to be reversed based on the message. Is it wrong?