PHP help: how do I express a series of binary values as a number?

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
AndyHolyer

PHP help: how do I express a series of binary values as a number?

Post by AndyHolyer »

I'm porting FrontEndUsers over to use our Active Directory server rather than the database, and I need a value for User ID.

I've found an ideal candidate: msexchmailboxguid, which is indeed unique for each user. However I've hit a problem: this attribute is a series of 16 hex bytes. PHP seems to insist on interpreting this value as a 16-character string, (which come out looking like this:  )¦§ð”MûE³rèm.), and without an asc() function I don't see how I can decompose this and turn it back into a number. Anyone got any suggestions?

Thanks in advance, Andy
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: PHP help: how do I express a series of binary values as a number?

Post by Dee »

Have you tried casting it to integer?

Code: Select all

(int) $bar
Regards,
D
AndyHolyer

Re: PHP help: how do I express a series of binary values as a number?

Post by AndyHolyer »

Dee wrote: Have you tried casting it to integer?

Code: Select all

(int) $bar
Regards,
D
Yes, I get 0, since it still treats it as a string.

I did eventually find the solution:

bin2hex gets me a hex string, which I can then pass to base_convert to get me an (absolutely huge) decimal number. I'm really glad that php no longer restricts itself to the advertised 32 bits maximim size. Though lord alone knows why M$ think they need quite such a huge identifier - so that every atom on the planet can have its own email address?
Post Reply

Return to “The Lounge”