0 Replies - 1603 Views - Last Post: 26 April 2012 - 01:44 PM

#1 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 367
  • Joined: 11-July 07

Crazy Text

Posted 26 April 2012 - 01:44 PM

Description: This might not be a useful function to you, but someone might be able to implement it somewhere - it's a fun script! :) Changes "Message" to either "MeSsAgE" or "mEsSaGe" - which ever you like.
function CrazyText($string, $first_letter_upper = true)
{
    $length = strLen($string);
    $output = "";
    
    for ( $i = 0; $i < $length; $i++ )
    {
        $char = substr($string, $i, 1);
        if ( $i % 2 == ($first_letter_upper?0:1) )
        {
            $output .= strtoupper($char);
        }
        else
        {
            $output .= strtolower($char);
        }
    }
    
    return $output;
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1