Nolongerused3921 Posted December 24, 2006 Share Posted December 24, 2006 Well I've been working on my new site, and I am having a bit of trouble... Permissions are stored as 16-bit bit strings (010101.. etc), and while this is all fine and dandy... I want to add a group system, and by doing so - I need to figure out how to merge two bit strings (In case someone is in two groups).So basically, I need to find out how to merge numbers like 0010100010 and 1001010011 so that I get 1011110011.Anyone able to help me? I know I can write a function pretty easy to do this... But it would be pretty slow, so I need to find the best possible way to do this (PHP functions would be ideal) Link to comment https://forums.phpfreaks.com/topic/31757-merging-two-bit-strings/ Share on other sites More sharing options...
zq29 Posted December 24, 2006 Share Posted December 24, 2006 This can be done quite simply with the bitwise operators, like so:[code]<?php$a = bindec("0010100010");$b = bindec("1001010011");$c = $a | $b;echo decbin($c);?>[/code]For more information, check the PHP manual, or even better, check out [url=http://www.phpfreaks.com/forums/index.php/topic,113143.0.html]Barands examples in our FAQ[/url] Link to comment https://forums.phpfreaks.com/topic/31757-merging-two-bit-strings/#findComment-147268 Share on other sites More sharing options...
Nolongerused3921 Posted December 24, 2006 Author Share Posted December 24, 2006 ...It was listed on php.net's manual? I was just there... Wow I'm out of it.Anyways, thanks a bunch :D, you just saved me a bunch of time and possibly money (Faster processing, less required cpu) Link to comment https://forums.phpfreaks.com/topic/31757-merging-two-bit-strings/#findComment-147273 Share on other sites More sharing options...
Nolongerused3921 Posted December 24, 2006 Author Share Posted December 24, 2006 After working with bitwise for awhile... Er, is there a library or at least a class/functions out there, for various bitwise operations? Link to comment https://forums.phpfreaks.com/topic/31757-merging-two-bit-strings/#findComment-147381 Share on other sites More sharing options...
Barand Posted December 25, 2006 Share Posted December 25, 2006 As SA suggestedhttp://www.phpfreaks.com/forums/index.php/topic,113143.msg459615.html#msg459615 Link to comment https://forums.phpfreaks.com/topic/31757-merging-two-bit-strings/#findComment-147425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.