LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-03-2009, 03:09 PM   #1
matt_heys
LQ Newbie
 
Registered: Jan 2008
Posts: 20

Rep: Reputation: 0
Storing multiple options in a single variable (binary addition?)


Sorry but I have no idea what this is called and googleing "Binary Options" just brings back financial websites.

I want to store a set of options as an integer e.g.

Option 1 = 1
Option 2 = 2
Option 3 = 4
Option 4 = 8

So if I tick 1 & 3 the value is 5, or 2, 3 & 4 the value is 14.

I want to do this in PHP, is there a pre defined function for it or does anyone know a pseudo code example?

I can probably store the values without a problem as it's just addition, but I won't know how to then read them properly. I can't think of a simple way of doing it.

Also does anyone know what this is called so I could Google it a bit more.
 
Old 04-03-2009, 03:38 PM   #2
matt_heys
LQ Newbie
 
Registered: Jan 2008
Posts: 20

Original Poster
Rep: Reputation: 0
FIXED

Someone at work just came back from the pub, Bitwise is what I need and I've found some info.

Sorry didn't expect anyone back in the office until Monday.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing table in variable DeepSeaNautilus Linux - Software 5 04-04-2009 01:45 PM
Storing part of a filename as a variable VTGuitarMan Programming 5 03-12-2008 06:47 AM
Storing binary data in MySQL take 2 drspin Programming 5 05-05-2006 03:26 PM
storing octal value in char variable hubabuba Programming 1 04-17-2006 12:53 AM
Can I have multiple desktop/manager options with single user? timsch75 Slackware 5 08-18-2004 05:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration