PHP uses substr () and Strpos () to federate a method of finding a specific character in a string, Substrstrpos
This example describes how PHP uses substr () and Strpos () to jointly find a particular character in a string. Share to everyone for your reference. The specific analysis is as follows:
Requirements: In the following string to find the characters in front of the double vertical bar, most of the empty under the use of the explode () function, but the project process using too many explode (), so found the following method.
<?php $str = "admin| | 46cc468df60c961d8da2326337c7aa58| | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, "; Echo substr ($str, 0,strpos ($str, "| |"));? >
The output content is admin.
SUBSTR () Specific description: http://www.bkjia.com/w3school/php/func_string_substr.htm
Strpos () Specific description: http://www.bkjia.com/w3school/php/func_string_strpos.htm
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/998548.html www.bkjia.com true http://www.bkjia.com/PHPjc/998548.html techarticle PHP uses substr () and Strpos () to find a method of a particular character in a string, Substrstrpos This example describes PHP using substr () and Strpos () to find a specific word in a string ...