Home > Backend Development > PHP Tutorial > Determine whether it is a legal zip code (fixed length) in PHP_PHP tutorial

Determine whether it is a legal zip code (fixed length) in PHP_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 16:59:49
Original
1039 people have browsed it

The purpose of this function is to determine whether it is a legal zip code (fixed length). The method is very simple, just use regular expressions to operate.

The code is as follows
 代码如下 复制代码


< ?php

// 函数名:CheckPost($C_post)

// 作 用:判断是否为合法邮编(固定长度)

// 参 数:$C_post(待check的邮政编码)

// 返回值:布尔值

// 备 注:无

//-----------------------------------------------------------------------------------

function CheckPost($C_post)

{

$C_post=trim($C_post);

if (strlen($C_post) == 6)

{

if(!ereg("^[+]?[_0-9]*$",$C_post))

{

return true;;

}else

{

return false;

}

}else

{

return false;;

}

}

?>

Copy code

< ?php

// Function name: CheckPost($C_post)

// Parameter: $C_post (postal code to be checked) //Return value: Boolean value // Remarks: None //--------------------------------------------- ----------------------------------------

function CheckPost($C_post)
{<🎜> <🎜>$C_post=trim($C_post);<🎜> <🎜>if (strlen($C_post) == 6)<🎜> <🎜>{<🎜> <🎜>if(!ereg("^[+]?[_0-9]*$",$C_post))<🎜> <🎜>{<🎜> <🎜>return true;;<🎜> <🎜>}else<🎜> <🎜>{<🎜> <🎜>return false;<🎜> <🎜>}<🎜> <🎜>}else<🎜> <🎜>{<🎜> <🎜>return false;;<🎜> <🎜>}<🎜> <🎜>}<🎜> <🎜>?> http://www.bkjia.com/PHPjc/631297.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631297.htmlTechArticleThe function of this function is to determine whether it is a legal zip code (fixed length). The method is very simple, just use regular expressions to operate. The code is as follows Copy code ?php // Function name: CheckPost($C_post) // Function...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template