Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating ascII value for a string

Status
Not open for further replies.

quan

Programmer
Oct 3, 2001
58
0
0
US
Hello,

Trying to convert a alpha string to a numerical value.
$string = "Big TV";
I would like to convert this to its ascii numerical equivalent which I will store in a new string

$newstring = "234234";


Thanks a million <i>Its okay to dream.....</i>
 
Code:
$string = &quot;Big TV&quot;;

@dec = unpack( &quot;C*&quot;, pack( &quot;A*&quot;, $string ) );
$hex = unpack( &quot;H*&quot;, pack( &quot;A*&quot;, $string ) );

$&quot; = &quot;&quot;;
print &quot;@dec\n&quot;;
print &quot;$hex\n&quot;;
Returns a choice of:
Code:
66105103328486  (decimal representation)
426967205456    (hexadecimal representation)
Cheers, Neil
 
Thanks Neil,

That is what I needed..................

U the man <i>Its okay to dream.....</i>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top