monkey_05_06 Posted April 12, 2007 Share Posted April 12, 2007 Is there any function that can be used to interpret a char as an int? AFAIK PHP doesn't distinguish between chars and strings (a char is simply a string with a length of 1 (right?)), so I haven't found/can't think of a way to do this. I imagine I might not be coming across very clear right now, so let me try to explain what I want. I want to convert a char, say 'A' to it's appropriate integer value, i.e., 65. Everything I've tried as far as conversion has simply led to the chars/strings casting to 0. Thanks for any help with this. - monkey Link to comment https://forums.phpfreaks.com/topic/46693-solved-interpreting-a-char-as-an-int/ Share on other sites More sharing options...
Guest prozente Posted April 12, 2007 Share Posted April 12, 2007 You would use ord, it "Returns ASCII value of character" echo ord('A'); //would return 65 Link to comment https://forums.phpfreaks.com/topic/46693-solved-interpreting-a-char-as-an-int/#findComment-227480 Share on other sites More sharing options...
monkey_05_06 Posted April 13, 2007 Author Share Posted April 13, 2007 Ah thank-you. That's exactly what I needed. The function is so descriptively named... I'm sure this has probably been brought up before, sorry for not searching 'round the forums first. I was just being lazy. Link to comment https://forums.phpfreaks.com/topic/46693-solved-interpreting-a-char-as-an-int/#findComment-228232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.