Php intercepts Chinese PHP strings
For example, Chengdu, Sichuan province
What I want to intercept is Sichuan province.
$ At = strpos ($ address, "province ");
$ Address = substr ($ address, 0, $ );
I don't know what went wrong. I didn't find a good article on the Internet for reference. I don't know which of the following experts can help me solve this problem.
It is mainly Chinese, and its length is different from that in English. I'm dizzy.
Who can give me a detailed answer and I will give 100 points. Thank you!
Reply to discussion (solution)
$ At = strpos ($ address, "province ");
$ Address = substr ($ address, 0, $ );
In this way, we can only intercept two words in Sichuan. I want Sichuan. when I am $ at + 1, there will be no value. I don't know why.
Calculate the length.
$ Address = 'Chengdu city, Sichuan province '; $ at = strpos ($ address, "province"); echo $ address = substr ($ address, 0, $ at + strlen ('Province '));
Sichuan
I didn't think of it. Thank you, moderator. Paste