richardoneill.com.au » Articles » Is the first character uppercase

Is the first character uppercase

9 March 2007 PHP, Programming

I needed to make a script in PHP to scan a page of text and return the top 10 keywords.

I decided to give more importance to words starting with uppercase characters. I couldn't find any PHP functions available, so I thought I would write my own. Hopefully someone finds this useful.


<?php
    $string 
'Titanic';
    
    function 
isFirstUC($string)
    {
        if(
strstr($string[0], ucfirst($string[0])))
            return 
True;
        else
            return 
False;
            
    }
    
    echo 
isFirstUC($string);
    
?>

Comment on this article
Name
Website
Canberra Web Design