Home  >  Article  >  Backend Development  >  The php code hidden by the characters behind the province and city

The php code hidden by the characters behind the province and city

小云云
小云云Original
2018-02-24 14:40:371609browse

This article mainly shares with you the method of hiding the characters behind provinces and cities in PHP. We will share it in the form of code, hoping to help everyone.

   //隐藏省市区后面的字符串,只显示到省市区
    public static function changeToArea($address)
    {
        if(strpos($address,'区') !== false) {
            $b = substr($address,0,strrpos($address,'区')).'区';
        }
        if(strpos($address,'县') !== false) {
            $b = substr($address,0,strrpos($address,'县')).'县';
        }
        if(strpos($address,'市') !== false && strpos($address,'县') !== false) {
            $b = substr($address,0,strrpos($address,'市')).'市';
        }
        return $b;
    }

Related recommendations:

php Issues related to string replacement where some characters are hidden and changed to *

The above is the detailed content of The php code hidden by the characters behind the province and city. For more information, please follow other related articles on the 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