This may sound strange but I am trying to find every possible cost for a bundle package with a communications company. (I'm trying to create a very detailed budget.) Because there was so many different possible combination I thought I would just code a loop and have php do the work for me. It seems it can't be that easy.
There is no error coming up with the code but it is resulting in the plan array:
Array ( [-10] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) [0] => Array ( [] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) [10] => Array ( [] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) [25] => Array ( [] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) [70] => Array ( [] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) [] => Array ( [] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => Array ( [0] => ) ) ) ) ) ) )
I'm sorry for posting the entire code but I'm really not sure where the problem is:
<?php
$base=39.98;
$tv_plan1=35;
$sports=array(0,5,10);
$digital_v=array(0,5,10);
$prem=array(0,14,26,36);
$hd=array(0,5,10);
$box=array(0,15,5,10);
$net=array(-10,0,10,25,70);
$tvs=array(0,1,2,3);
$possibilities=array();
$sports1=0;
$digital_v1=0;
$prem1=0;
$hd1=0;
$box1=0;
$net1=0;
$tv1=0;
$tax=1.06;
$a=0;
$b=0;
$c=0;
$d=0;
$e=0;
$f=0;
$g=0;
while ($a <=5)
{
$net1=$net[$a];
if ($b >=4)
{
$box1=$box[$b];
}
else
{
$b=0;
$box1=$box[$b];
}
if ($c >=3)
{
$hd1=$hd[$c];
}
else
{
$c=0;
$hd1=$hd[$c];
}
if ($d>=4)
{
$prem1=$prem[$d];
}
else
{
$d=0;
$prem1=$prem[$d];
}
if ($e>=3)
{
$digital_v1=$digital_v[$e];
}
else
{
$e=0;
$digital_v1=$digital_v[$e];
}
if ($f>=3)
{
$sports1=$sports[$f];
}
else
{
$f=0;
$sports1=$sports[$f];
}
if ($g>=4)
{
$tv1=$tvs[$g];
}
else
{
$g=0;
$tv1=$tvs[$g];
}
$box1*$tvs=$box2;
$net1+$box2+$hd1+$prem1+$digital_v1+$sports1+$tv_plan1+$base=$subtotal;
$subtotal*$tax=$total;
$possibilities[$net1][$tv1][$box1][$hd1][$prem1][$digital_v1][$sports1]=$total;
$a++;
$b++;
$c++;
$d++;
$e++;
$f++;
$g++;
}
echo "First: Price of Net,";
echo "<br>";
echo "<br>";
echo "Second: Number of Tvs,";
echo "<br>";
echo "<br>";
echo "Third: Price of Box Option,";
echo "<br>";
echo "<br>";
echo "Fourth: Price of HD Option,";
echo "<br>";
echo "<br>";
echo "Fifth: Price of Prem. Channels option,";
echo "<br>";
echo "<br>";
echo "Sixth: Price of Digital View Option,";
echo "<br>";
echo "<br>";
echo "Seventh: Price of Sports package Option";
echo "<br>";
echo "<br>";
print_r($possibilities);
?>
To give you some in sight into the code: the outcome was suppose to be an array with the locations in the arrays coming for the various varibles so I could tell what combination the resulting price was for.
Thank you for the help.