How to convert a string characters: upper to lower and lower to upper in PHP

1 Answer

0 votes
    $s = "Convert a HARD DISK or partition TO NTFS format";
    $i = 0;
         
    while ($i < strlen($s))
    {
        if (ctype_lower($s[$i]))
            $s[$i] = strtoupper($s[$i]);
        else if (ctype_upper($s[$i]))
                 $s[$i] = strtolower($s[$i]);
        $i++;
    }
    
    echo $s;
    
    /*
    run:
    
    cONVERT A hard disk OR PARTITION to ntfs FORMAT
    
    */


answered May 29, 2015 by avibootz
...