|
Posted by Chris H on 04/06/06 02:48
see the problem is i really need the array values to come from a string
variable, this way the administartor can easily set/modify the payout
percentage "range" witrhin teh variables.php file, so the admin never has to
be in the main parts of my code, i guess i could always just use mySQL and
have the ranges set in a table for the scripts configs. altho i really am
trying to keep from using MySQL so much to relieve any server strain
"David Haynes" <david.haynes2@sympatico.ca> wrote in message
news:GYXYf.73009$nF1.22196@fe64.usenetserver.com...
> Chris H wrote:
>> Okay, I am trying to us a varialble with a list of number values as my
>> data for an array, yet when I do this it doesnt return any values from
>> the array, i was able to temporarily fix the proble by just doing s
>> normal array setup in my function, but the problem is I want the ability
>> to have teh array values to be changed easily in a varibale style
>> config/include file... Here is the code i am working with...
>>
>>
>> ===================================
>> VARIABLE.PHP (my config variables)
>> ====================================
>> <?php
>>
>> $pid_prefix = "LPPA";
>>
>> $site_domain = "www.lafayettepoker.com";
>> ######################################
>> # PAYOUT PERCENTAGE STRUCTURE
>> ######################################
>> $range1 = ".60, .30, .10";
>> $range2 = ".50, .30, .12, .06, .02";
>> $range3 = "'.33, .17, .14, .12, .10, .06, .05, .04, .03, .02";
>> $range4 = ".25, .15, .10, .08, .07, .05, .05, .04, .03, .03, .02, .02,
>> .02, .02, .02, .01, .01, .01, .01, .01";
>> $range5 = "";
>> $range6 = "";
>> ######################################
>> # POINT POOL
>> ######################################
>> $pool = "5000";
>>
>>
>> ?>
>> =======================================
>> MAIN PART OF SCRIPT
>> =======================================
>> <?php
>> require ('variables.php');
>>
>>
>>
>> if ($tplayer >= 5 && $tplayer <= 10) {
>> $table = $range1;
>> }
>> elseif ($tplayer >= 11 && $tplayer <= 17) {
>> $table = $range2;
>> }
>> elseif ($tplayer >= 18 && $tplayer <= 35) {
>> $table = $range3;
>> }
>> elseif ($tplayer >= 36 && $tplayer <= 65) {
>> $table = $range4;
>> }
>> elseif ($tplayer >= 66 && $tplayer <= 99) {
>> if ($range5 == '') { $table = "$range4"; }
>> else { $table = "$range5"; }
>> }
>> elseif ($tplayer >= 100) {
>> if ($range6 == '') { $table = "$range4"; }
>> else { $table = "$range6"; }
>> }
>> else {
>> $msg = "Not Enough Players";
>> print_error_msg($msg);
>> }
>> calculate_points($table,$rank);
>>
>>
>>
>>
>> function calculate_points($table,$rank) {
>> global $pool;
>> $index = ($rank - 1);
>> $perc = array($table);
>> $total_points = $pool * $perc["$index"];
>> $total_points = round($total_points);
>> print "$total_points<br>";
>> }
>>
>>
>> // PRINT ERROR TO SCREEN
>> function print_error_msg($msg) {
>> print "$msg";
>> }
>>
>> ?>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> Ive also tried a few differnt variatons of teh above, including
>> formatting the $range string to look similiar to an array, in other words
>> i addded in sigle-quotes so the range variables would look like this
>> $range1 = " '.60', '.30', '.10' "; (note the spaces seperating the
>> double and single quoute, is just there to show that there are 2 types of
>> quotes used)
>>
>> Ok I will test this after i post this since i dont htink it will work
>> anyway, but looking at the above string, is it possible the reason that
>> string didnt works is because i didnt escape teh sigle quotes, and if
>> that is the case how come it doesnt work without teh single quotes at
>> all.. I really am not sure of what i am doing wrong here...
>
> Either:
>
> $table = array( .60, .30, .10 );
> or
> $table = explode(', ', ".06, .30, .10");
>
> should work for you.
>
>
Navigation:
[Reply to this message]
|