Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Check if string contains a letter

I am creating a login and want to allow my users to login either by username or email. How would I check if a string contains a letter, in this case @ so I can handle it correctly. Would I use strstr or strpos? Thanks!

like image 219
Joe Torraca Avatar asked Nov 25 '25 11:11

Joe Torraca


1 Answers

To just check if string contains a letter you could use

if (strpos($source_string, $letter) !== false) { ... }
like image 160
zerkms Avatar answered Nov 28 '25 01:11

zerkms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!