Jump to content

Exchange Symbol Cases.

- - - - -

  • Please log in to reply
1 reply to this topic

#1
VakhoQ

VakhoQ

    Programmer

  • Members
  • PipPipPipPip
  • 127 posts
I have written function that :
1) turns the small Symbols into upper case symbols. And Also:
2) turns the upper case symbols into smoller case symbols.

function N($str)

{

   for($i=0; $i<=strlen($str); $i++)

   {

   

       if(ord($str[$i])>=97 && ord($str[$i]<=122)){

	   $str[$i]=chr(ord($str[$i])-32);

	   }

	   else if(ord($str[$i])>=65 && ord($str[$i]<=90)){

	   $str[$i]=chr(ord($str[$i])+32);

	   }

	   

   }

   echo $str;

}


$str="ABC abc";

N($str); 



everything works well, but if i write "else" instead of "else if", it does not works. I don't understand why?
GNU/Linux Is the Best.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Well, space is not in either of those ranges.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users