Couldn't find a function for this. I'm assuming I need to use regex?
I'm trying to do html redirects in php in cases where the url contains at least 1 upper case letter.
example: http://www.domain.com/Michael_Jordan needs to be redirected to http://www.domain.com/michael_jordan - only problem is I can't seem to find a script to detect if at least 1 capital letter exists.
PHP | ctype_upper() Function The ctype_upper() function in PHP used to check each and every character of a given string is in uppercase or not. If the string in upper case then it returns TRUE otherwise returns False.
The is_numeric() function checks whether a variable is a number or a numeric string. This function returns true (1) if the variable is a number or a numeric string, otherwise it returns false/nothing.
The islower() method returns True if all alphabets in a string are lowercase alphabets. If the string contains at least one uppercase alphabet, it returns False.
Some regular expression should be able to the work, you can use preg_match
and [A-Z]
if(preg_match('/[A-Z]/', $domain)){ // There is at least one upper }
if (strtolower($url) != $url){ //etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With