Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7502041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:44:07+00:00 2026-05-29T20:44:07+00:00

Background; to create a dropdown menu for a fun gambling game (Students can ‘bet’

  • 0

Background;
to create a dropdown menu for a fun gambling game (Students can ‘bet’ how much that they are right) within a form.

Variables;
$balance
Students begin with £3 and play on the £10 table

$table(there is a;

£10 table, with a range of 1,2,3 etc to 10.

£100 table with a range of 10,20,30 etc to 100.

£1,000 table with a range of 100, 200, 300, 400 etc to 1000.)

I have assigned $table to equal number of zeros on max value,
eg $table = 2; for the £100 table

Limitations;
I only want the drop down menu to offer the highest 12 possible values (this could include the table below -IMP!).
Students are NOT automatically allowed to play on the ‘next’ table.

resources;
an array of possible values;

$a = array(1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000);

I can write a way to restrict the array by table;
(the maximum key for any table is (9*$table) )//hence why i use the zeroes above (the real game goes to $1 billion!)

$arrayMaxPos = (9*$table);
$maxbyTable = array_slice($a, 0, $arrayMaxPos);

Now I need a way to make sure no VALUE in the $maxbyTable is greater than $balance.
to create a $maxBet array of all allowed bets.

THIS IS WHERE I’M STUCK!

(I would then perform “array_slice($maxBet, -12);” to present only the highest 12 in the dropdown)

EDIT – I’d prefer to NOT have to use array walk because it seems unnecessary when I know where i want the array to end.

SECOND EDIT Apologies I realised that there is a way to mathematically ascertain which KEY maps to the highest possible bid.

It would be as follows

$integerLength = strlen($balance);//number of digits in $balance


$firstDigit = substr($balance, 0, 1); 

then with some trickery because of this particular pattern

$maxKeyValue = (($integerlength*9) - 10 + $firstDigit);

So for example;

$balance = 792;

$maxKeyValue = ((3*9) - 10 + 7);// (key[24] = 700)

This though works on this problem and does not solve my programming problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:44:07+00:00Added an answer on May 29, 2026 at 8:44 pm

    Optional!

    First of all, assuming the same rule applies, you don’t need the $a array to know what prices are allowed on table $n

    $table = $n; //$n being an integer
    for ($i = 1; $i <= 10; $i++) {
        $a[] = $i * pow(10, $n);
    }
    

    Will generate a perfectly valid array (where table #1 is 1-10, table #2 is 10-100 etc).


    As for slicing it according to value, use a foreach loop and generate a new array, then stop when you hit the limit.

    foreach ($a as $value) {
        if ($value > $balance) { break; }
        $allowedByTable[] = $value;
    }
    

    This will leave you with an array $allowedByTable that only has the possible bets which are lower then the user’s current balance.


    Important note

    Even though you set what you think is right as options, never trust the user input and always validate the input on the server side. It’s fairly trivial for someone to change the value in the combobox using DOM manipulation and bet on sums he’s not supposed to have. Always check that the input you’re getting is what you expect it to be!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background Create a Map that can be sorted by value. Problem The code executes
I want to create a background thread that's owned by an object. When that
i'm working with a multi-threaded program (using pthreads) that currently create a background thread
Background: I'm trying to create a pure D language implementation of functionality that's roughly
I am trying to create dropdown menu for Wordpress theme and having some silly
I'm using jQuery to create a simple, but large dropdown menu. I have some
Is there a way to create a background image for a UIView that is
I'm trying to create a page with a navigation bar that has dropdown submenus.
Background: On a recent website, I'm using a jQuery driven dropdown menu in addition
Trying to create a background-image slideshow and am getting this error... This is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.