ASCII Chars Only

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Trying to get the following working. I am trynig to select only ASCII characters (not extended ASCII) so that if the string contains characters outside the 32 - 126 range of "good" characters then $Discard is returned as > 0.

But it is going overboard telling me that every character is bad :(

Ideas?

Cheers
Richard


	$test = "飯島真�as";
	
	function non_ascii($str) {	
		$Discard = 0;
		
		for ($i=0; $i < strlen($str); $i++)
		{
			$char = ord($test{$i});

			if (($char < 32 || $char > 126)) {
				$Discard++;
			}
		}	
		
		return $Discard;
	}
	
	print non_ascii($test);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux