Jump to content

Recommended Posts

ctype_alpha("$value") letters only

ctype_digit("$value") numbers only

ctype_alnum("$value") letters and numbers only

 

above can only equal true or false

 

 

$value="hello world";

 

if (ctype_alpha("$value")==true)

{echo "Good Job";}

else

{echo "WTF?";}

 

 

output=> Good Job

Thanks to both of you!

 

I didn't realize there is a regex section of the board. I will have to use that in the future.

 

I need a regex expression. I'm actually not testing for alphabetic characters to tell the truth, I'm testing for Japanese kana, so the three functions in the previous post wont work. But I didn't think anyone here would know how to write regex expressions for Japanese, so I'm just going to substitute from a regex expression.

Thanks for the help everyone. I managed to get my code working. I thought it would be as simple as substituting the first and last katakana (one of the Japanese alphabets) into the English regex, but it wasn't. In the end, it was this code that did it for me:

 

if (mb_ereg('[。-゚]', $string))
{
echo "string is katakana";
}
else
{
echo "string is not katakana";
}

 

I don't imagine that many people will need this code for anything, but I thought I would post it here in case someone searches for it sometime.

 

Note: This works in EUC-JP encoding. I don't know and doubt that it will work with other encodings (Shift_JIS and utf-8 for example)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.