Code function
01.function strlenth($str)02.{03.$arr = str_split($str);04.$count = 0;05.foreach($arr as $val)06.{07.$ascii = ord($val);08.if(!( $ascii == 209 || ($ascii >= 212 && $ascii <= 218 ) || ($ascii >= 231 && $ascii <= 238 )))09.$count += 1;10.}11.return $count;12.}Example
Code
1.$str = "นครราชสีมา ครับ";2.echo strlenth($str);หมายเหตุ หน้าเพจที่จะใช้ฟังก์ชั่นนี้ ต้องเซตแบบนี้นะครับ จึงจะนับได้ถูกต้อง
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
No comments:
Post a Comment