Home Backend Development PHP Tutorial Regarding the problem of character string segmentation with mixed Chinese and English numbers_PHP tutorial

Regarding the problem of character string segmentation with mixed Chinese and English numbers_PHP tutorial

Jul 13, 2016 pm 05:38 PM
about Split word count number Serve of Short message SMS platform end want question limit

Because you need to use a text message platform, each text message has a character limit, and the server of the text message platform does not analyze it by itself.

Sigh, the background of the SMS platform will be divided by itself, but the API does not have this function.

I spent some time searching online and found nothing.

Later, I came up with a way, which I think is original.

Just use the interception and replacement function.

The code is as follows:

CODE:

<code style="border: 1px solid rgb(204, 204, 204); margin: 0pt 1em 1em; padding: 0.5em; display: block; font-family: Courier,monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; font-size-adjust: none; font-stretch: normal; line-height: 1.8em;"> <br> function smssubstr($string, $length) {<br> if(strlen($string) <= $length) {<br /> return $string;<br /> }<br /> $strcut = ;<br /> for($i = 0; $i < $length; $i++) {<br /> $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];<br> }<br> return $strcut;<br> }<br> for($i=1; $i<=$smsnum; $i++){<br /> ${smscontent.$i} = smssubstr($message,$smsper);<br /> $message = str_replace(${smscontent.$i},"",$message);<br /> } function smssubstr($string, $length) {

if(strlen($string) <= $length) {

return $string;

} for($i = 0; $i < $length; $i++) { $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i]; } return $strcut; } for($i=1; $i<=$smsnum; $i++){ ${smscontent.$i} = smssubstr($message,$smsper); $message = str_replace(${smscontent.$i},"",$message); } http://www.bkjia.com/PHPjc/486496.html
www.bkjia.com
truehttp: //www.bkjia.com/PHPjc/486496.htmlTechArticleBecause you need to use the SMS platform, each text message has a word limit, and the server of the SMS platform has I don’t know how to analyze myself. Sweat, the background of the SMS platform will be divided by itself, but the API does not have this...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to remove comment restrictions on video accounts? What is the word limit for comments on a video account? How to remove comment restrictions on video accounts? What is the word limit for comments on a video account? Mar 22, 2024 pm 02:11 PM

With the popularity of video accounts on social media, more and more people are beginning to use video accounts to share their daily lives, insights and stories. However, some users may experience comments being restricted, which can leave them confused and dissatisfied. 1. How to remove comment restrictions on video accounts? To lift the restriction on commenting on a video account, you must first ensure that the account has been properly registered and real-name authentication has been completed. Video accounts have requirements for comments. Only accounts that have completed real-name authentication can lift comment restrictions. If there are any abnormalities in the account, these issues need to be resolved before comment restrictions can be lifted. 2. Comply with the community standards of the video account. Video accounts have certain standards for comment content. If the comment involves illegal content, you will be restricted from speaking. To lift comment restrictions, you need to abide by the community of the video account

How to check word count in word? How to check word count in word How to check word count in word? How to check word count in word Mar 04, 2024 am 10:04 AM

Word is one of the most popular office software. Sometimes there are strict word count requirements for the formatting of documents. For example, the number of words in a title should not be too long. A title that is too long is not eye-catching enough. There are also certain paragraphs that need to be put into some software systems. Too many or too few words will affect the beauty of the layout. If you count the words one by one, it will look dull and a waste of time. You may even count the words incorrectly. How do you check the number of words in Word? Let’s learn several ways to check word count in Word. How to check word count in word? How to check the word count in Word The first method is to use Word word count to check 1. Select the "Review" tab and click "Word Count" to count the number of pages, words, characters, paragraphs, lines, etc. of the document. information. Hold

What is the correct way to restart a service in Linux? What is the correct way to restart a service in Linux? Mar 15, 2024 am 09:09 AM

What is the correct way to restart a service in Linux? When using a Linux system, we often encounter situations where we need to restart a certain service, but sometimes we may encounter some problems when restarting the service, such as the service not actually stopping or starting. Therefore, it is very important to master the correct way to restart services. In Linux, you can usually use the systemctl command to manage system services. The systemctl command is part of the systemd system manager

Solution to Ubuntu PHP service failing to start normally Solution to Ubuntu PHP service failing to start normally Feb 28, 2024 am 10:48 AM

Title: Methods and specific code examples to solve the problem that the PHP service cannot start normally under Ubuntu. When using Ubuntu to build a website or application, you often encounter the problem that the PHP service cannot start normally, which will cause the website to be unable to be accessed normally or the application to be unable to function normally. run. This article will introduce how to solve the problem that the PHP service cannot start normally under Ubuntu, and provide specific code examples to help readers quickly solve such failures. 1. Check the PHP configuration file First, we need to check the PHP configuration file

What should I do if the maximum size of documents that WPS members can upload exceeds the limit? What should I do if the maximum size of documents that WPS members can upload exceeds the limit? Mar 20, 2024 pm 06:40 PM

WPS is an office software that integrates comprehensive operations. You can now download WPS for use, but if you want to have more functions, you need to register as a member. Some people may wonder what is the maximum file size that a WPS member can upload? If you are a WPS member user, you can upload files up to 1G each time, and all files can add up to 365G. There may be some differences in different terminals, but the overall display is basically similar. What should I do if I cannot upload beyond the limit? We will explain it next. 1. When uploading files, such as cloud documents, there is a certain amount of space. If it exceeds the size, it cannot be uploaded. 2. Click on the membership logo, purchase membership according to your needs, and expand the space. 3. Coupons may appear occasionally, so don’t forget to use them.

How to execute service restart command in Linux? How to execute service restart command in Linux? Mar 14, 2024 am 11:06 AM

In Linux, to execute the service restart command, you usually need to use the Systemd service manager. Systemd is a widely used service management tool on Linux, which can easily manage and control system services. The following will introduce how to execute the service restart command through Systemd in Linux and provide specific code examples. Step 1: Confirm the service name. Before executing the service restart command, you first need to confirm the name of the service to be restarted. You can view the list of services running on the system with the following command:

How to recover deleted text messages on Apple mobile phone How to recover deleted text messages on Apple mobile phone Mar 08, 2024 pm 03:19 PM

Some important text messages have been deleted from Apple mobile phone text messages, and many users don’t know how to recover them. In fact, the recovery method is also very simple. Today I will share with you the detailed recovery method. How to recover deleted text messages on Apple mobile phone? Answer: There are four methods, namely iCloud recovery, iTunes recovery, third-party software recovery and operator recovery 1. If the user uses icloud to back up the text message data of his mobile phone, he can directly use icloud Data recovery. 2. Just go to [Settings]>[General]>[Restore], then restore from iCloud backup, and select the most recent text message backup. 3. If the user uses iTunes to back up his mobile phone, then the player only needs to

Does Oracle Database provide free services? Does Oracle Database provide free services? Mar 07, 2024 pm 10:00 PM

"Does Oracle Database provide services for free? 》Oracle database is a leading enterprise-level relational database management system that is widely used for data management and storage in many large enterprises and organizations. With the development and popularization of database technology, many people are concerned about whether Oracle database provides free services. In this article, we will explore the free and paid services of Oracle Database and analyze their advantages and disadvantages. Free Service Oracle offers a free version of its database product called Orac

See all articles