码迷,mamicode.com
首页 > 其他好文 > 详细

如何判断字符串是否为纯字母

时间:2018-09-05 11:40:23      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:spl   val   check   return   foreach   aar   rar   cti   array   

function checkStrIsLetter($str){
		$letteraArr = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
		$letterAArr = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ");
		//字母表
		$letter = array_merge($letteraArr,$letterAArr);
		//分割字符
		$strArr = str_split($str);
		//循环判断
		if(!empty($strArr)){
			foreach($strArr as $key=>$val){
				if(!in_array($val,$letter)){
					return "no";
					exit;
				}
			}
		}else{
			return "no";
		}
		return "yes";
	}

  

如何判断字符串是否为纯字母

标签:spl   val   check   return   foreach   aar   rar   cti   array   

原文地址:https://www.cnblogs.com/void9main/p/9591081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!