Getting ascii value of a char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron Gray

    Getting ascii value of a char

    Given :-

    $text="abc";

    $ch = $text{0}; // index character 0 in $text

    how do I get the value 65 from $ch as an integer ?

    Many thanks in advance,

    Aaron


  • =?iso-8859-1?Q?=C1lvaro?= G. Vicario

    #2
    Re: Getting ascii value of a char

    *** Aaron Gray escribió/wrote (Mon, 24 Mar 2008 20:50:18 -0000):
    $text="abc";
    >
    $ch = $text{0}; // index character 0 in $text
    You'd better get used to $text[0]. Apparently, the PHP guys will deprecate
    the first syntax in PHP 6.

    how do I get the value 65 from $ch as an integer ?
    ord()


    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor en cubitos: http://www.demogracia.com
    --

    Comment

    • Aaron Gray

      #3
      Re: Getting ascii value of a char

      "Álvaro G. Vicario" <webmasterNOSPA MTHANKS@demogra cia.comwrote in message
      news:16xr3ovmn0 j4k$.1ik3o5ph82 kjb.dlg@40tude. net...
      *** Aaron Gray escribió/wrote (Mon, 24 Mar 2008 20:50:18 -0000):
      >$text="abc";
      >>
      >$ch = $text{0}; // index character 0 in $text
      >
      You'd better get used to $text[0]. Apparently, the PHP guys will deprecate
      the first syntax in PHP 6.
      Okay, thanks.
      >how do I get the value 65 from $ch as an integer ?
      >
      ord()
      Great, thanks alot,

      Aaron


      Comment

      Working...