Idan Neeman
Idan Neeman

Reputation: 119

If conditions with range

I have code:

$firstletter = mb_substr($userData['name'], 0, 1, 'UTF-8');
if ($firstletter=='א') {
    ...
}
if ($firstletter=='a') {
    ...
}

and I want to make the if in range, like:

if($firstletter>'a' && $firstletter<'c')

or

if($firstletter>'א' && $firstletter<'ה')

it's possible to write this?

Upvotes: 1

Views: 103

Answers (2)

Ostin
Ostin

Reputation: 1541

You can use ord() function that returns ASCII code of letter passed. But you have to be sure that only Latin letters are passed. For unicode support check out comments on ord() function

Upvotes: 2

DiverseAndRemote.com
DiverseAndRemote.com

Reputation: 19888

yes it is possible and you just wrote it.

Upvotes: 4

Related Questions