#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    I looked in the PHP manual and I couldn't find what I was looking for. I need a function that will return the ANSI code value for a character. E.g. "a" should return 97.

    In ASP the function is Asc() if that helps anyone (I'm switching from ASP to PHP...) Thanks
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Bucharest, Romania
    Posts
    18
    Rep Power
    0
    The function you look for is Ord(string); it returns the ASCII code of the first character of the string.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    15
    FYI: ASCII codes from 1 to 127 are the same, but above they differ across different operating systems. Use chr() to get character from ASCII code and ord() to go the opposite way.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?
    // print lowercase a from ASCII
    print(chr(97));
    // print ASCII from lowercase a
    print(ord("a"));
    ?>
    [/code]


    ------------------
    <UL TYPE=SQUARE>
    <LI> TD Scripts
    <LI> Script School
    <LI>php-scripts
    </UL>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    Well, I did find those functions, but I guess considering the values above 127 vary I'll have to find out what they are.

    What I'm really trying to do is implement an RC4 encryption program into PHP, and that's one of the functions for the encryption.

Similar Threads

  1. Extended characters (&# codes) don't work in FPDF...
    By 80sDweeb in forum PHP Development
    Replies: 0
    Last Post: January 2nd, 2004, 01:44 PM
  2. About character codes...
    By Zenaida in forum C Programming
    Replies: 0
    Last Post: December 22nd, 2003, 08:11 AM
  3. w3c strict errors (10), css, and js questions
    By WorldBuilder in forum CSS Help
    Replies: 12
    Last Post: November 6th, 2003, 05:48 AM
  4. Replies: 1
    Last Post: July 15th, 2003, 12:47 PM

IMN logo majestic logo threadwatch logo seochat tools logo