Question about function chr ( )

Discussion in 'PHP' started by granGripau, Oct 12, 2009.

  1. #1
    I thought that I could double up chr like this:

    $input = "5";
    $output = chr(chr($input));
    echo $output

    so that $output would output the input.
    but when I try it out I don't get any response...
    did I just invent this? I thought I saw it somewhere...

    if so, is there another function that does this?

    Thanks!!!
     
    granGripau, Oct 12, 2009 IP
  2. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I don't think this will work as you expect it as chr expects a int as input and it would get a string as input in the second instance.
    If you use ord it will work as you expect:
    <?php echo ord(chr("5"));?>
    PHP:
     
    superdav42, Oct 12, 2009 IP
  3. granGripau

    granGripau Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Superdav42,

    Worked like a charm ! :)
     
    granGripau, Oct 12, 2009 IP