Home > Backend Development > PHP Tutorial > Detailed explanation of how to intercept the first non-zero position in a string using PHP

Detailed explanation of how to intercept the first non-zero position in a string using PHP

墨辰丷
Release: 2023-03-27 21:54:02
Original
2216 people have browsed it

This article mainly introduces the method of finding the first non-0 position in a string in PHP and intercepting it. It has a very good reference value. Let’s take a look at it with the editor.

Not much to say , please see the code:

$str = '00000000000000000000000000000000000000001234506';
$preg = '/[0]*/';
$result = preg_replace($preg, '', $str, 1);
Copy after login

##The above is the entire content of this article, I hope it will be helpful to everyone Learning helps.


Related recommendations:

Detailed explanation of the method of flipping string in php

php gets the stringmethod for the first few digits

php implements the string format through eval Calculation formula

The above is the detailed content of Detailed explanation of how to intercept the first non-zero position in a string using PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template