You are here: Uisng a string varibale with an array « All PHP « IT news, forums, messages
Uisng a string varibale with an array

Posted by Chris H on 04/06/06 01:41

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...

 

Navigation:

[Reply to this 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

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