Home >Backend Development >PHP Tutorial >PHP searches for the first non-zero position in a string and intercepts it

PHP searches for the first non-zero position in a string and intercepts it

高洛峰
高洛峰Original
2017-03-01 17:02:131115browse

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);

PHP searches for the first non-zero position in a string and intercepts it

More PHP search string interception of the first non-0 position related articles Please pay attention to PHP Chinese website!

Statement:
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