数据格式如下 23424-234234,怎么通过‘-’取得这个字符串后面的数值(数字位数是不定的),正则是真不会用
回复讨论(解决方案)
用php处理好了再传给smary 就是了。
这个用explode就行了。不是碰到什么都用正则
lz目的不就是要截取'-'之后的字符串吗
substr 就可以截取,或者二楼的explode也可以!
$a='23424-234234222222222';$b = substr($a,6);print_r ($b);
结果 234234222222222
或者
$a='23424-234234222222222';$b = explode('-',$a);print_r ($b);
结果 Array ( [0] => 23424 [1] => 234234222222222 )
然后
print_r($b[1]);
lz目的不就是要截取'-'之后的字符串吗
substr 就可以截取,或者二楼的explode也可以!
PHP code
?
1234
$a='23424-234234222222222'; $b = substr($a,6); print_r ($b);
结果 234234222222222
或者
PHP code
?
123
……
在smarty模板里唉,不是php页面。
用php处理好了再传给smary 就是了。
用php就有点乱了,应为牵涉到多个数组
引用 3 楼 nzr_dream 的回复:
lz目的不就是要截取'-'之后的字符串吗
substr 就可以截取,或者二楼的explode也可以!
PHP code
?
1234
$a='23424-234234222222222'; $b = substr($a,6); print_r ($b);
结果 234234222222222
或者
PHP code
?
123
……
在smarty模板里唉,不是php页面。
那就用smarty中的截取字符串函数啊 truncate
{$s|regex_replace:"/\d+-/":""}
smarty 本身是由php编写的模版 不行就写个截字符函数放到smarty函数库目录,一样好使
能不用正则就别用正则

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version
Recommended: Win version, supports code prompts!

Atom editor mac version download
The most popular open source editor

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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
