Reply to Re: Uisng a string varibale with an array

Your name:

Reply:


Posted by Chris H on 04/06/06 03:51

nevermind i figured it out, just have to make the config variables as arrays
instead, i dunno tho for some reason that variation didnt work earlier must
of had syntax error somewhere.

thanks agian for ur help all

"Chris H" <lppa2004@insightbb.com> wrote in message
news:3HYYf.667749$084.20176@attbi_s22...
> 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.
>>
>>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация