stualk Posted September 12, 2007 Share Posted September 12, 2007 I'm trying to get my head around arrays (been trying for years and i'm still none the wiser!). Take a look at the code below. I'm basically trying to gather together six lots of information into an array, sort it into numerical order and then display it. It's working to an extent, i've put the output below the code. You can see by the last line that the numerical values are in order, which is what I want. I just don't want it to look like that! $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); natsort($TOTALS); print_r($TOTALS); Array ( [4] => [5] => [3] => [2] => [1] => [0] => 2,984.15 ) Array ( [4] => [5] => [3] => [2] => [0] => 2,984.15 [1] => 3,119.39 ) Array ( [5] => [4] => [3] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 ) Array ( [5] => [4] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 ) Array ( [5] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 [4] => 3,477.37 ) Array ( [0] => 2,984.15 [5] => 3,022.03 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 [4] => 3,477.37 ) Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/ Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 Could you display your coding? Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346816 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 //====== This bit repeats six times to create six different calculations========= if ($supplier_name == "One") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6, 2); } //===================== $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); natsort($TOTALS); print_r($TOTALS); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346822 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 OK; well looking at your coding... 1. $TOTAL_REDUCED_1 ; TOTAL_REDUCED_2 ; TOTAL_REDUCED_3 ; TOTAL_REDUCED_4 ; TOTAL_REDUCED_5 dont exist. how are these defined? Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346825 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 The code below is repeated six times with the difference being the last two lines are called $TOTAL_REDUCED_1, $TOTAL_REDUCED_2, etc. to give six different calculations. I didn't copy and paste it all as it's rather a lot of code! if ($supplier_name == "One") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6, 2); } Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346826 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 ahh i'm with you. didnt you think to use for()? lol anyway. let's start again; sorry. Whats the problem? (detailed as possible) what are you trying to archieve? Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346827 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 Ok well i'm useless with arrays so I could maybe have worked out each of the $TOTAL_REDUCED figures using an array had I known how to! After the six sections where it works out the $TOTAL_REDUCED amounts I need an array to sort the amounts into order and then display them, preferably in rows. The first row needs to be the lowest amount and go through to the last row displaying the highest amount. As you can see from my first post I seem to have got some sort of array to sort the items into order but the output looked horrible and I don't know why! I've never been able to grasp arrays so if my coding is completely wrong it wouldn't surprise me in the slightest! Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346831 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 Well I know arrays in some depth; ok do this... (i know you did it but patse the output in code tags) print_r($TOTAL); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346834 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 Output is as follows: Array ( [4] => [5] => [3] => [2] => [1] => [0] => 2,984.15 ) Array ( [4] => [5] => [3] => [2] => [0] => 2,984.15 [1] => 3,119.39 ) Array ( [5] => [4] => [3] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 ) Array ( [5] => [4] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 ) Array ( [5] => [0] => 2,984.15 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 [4] => 3,477.37 ) Array ( [0] => 2,984.15 [5] => 3,022.03 [1] => 3,119.39 [2] => 3,176.89 [3] => 3,278.73 [4] => 3,477.37 ) Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346838 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 and... print_r($TOTAL[0]); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346840 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 That simply outputs the following, which is much tidier for starters: 2,984.15 2,984.15 2,984.15 2,984.15 2,984.15 2,984.15 Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346849 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 ok. to display your array for this... <? $total=count($TOTAL[0]); for($i=0; $<$total; $i++) { echo($TOTAL[0][$i]."\n"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346854 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 That returns an error on the second line of the code! Looks like it's for the less than part of it. Parse error: syntax error, unexpected '<', expecting T_VARIABLE or '$' Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346865 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 sorry. try this; i forgot the i on my var. <? $total=count($TOTAL[0]); for($i=0; $i<$total; $i++) { echo($TOTAL[0][$i]."\n"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346868 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 That's returned a series of 2's, like this: 2 2 2 2 2 2 Is that because i've got a comma in the numerical result and i'm displaying them to 2 decimal places, possibly? Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346878 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 Ok. try this... natsort($TOTALS[0]); or remove it compeltely then paste the output. Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346882 Share on other sites More sharing options...
sasa Posted September 12, 2007 Share Posted September 12, 2007 if you want to output array just ones move print_r function outside 6 loops you can change print_r($TOTAL) with foreach($TOTAL as $v) echo $v, '<br />'; Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346906 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 No that's just outputting a series of 2's again. These are the kind of problems i've been getting when I tried to code it myself....frustrating!! Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346912 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 print_r($TOTAL[0][0]); print_r($TOTAL[0][1]); print_r($TOTAL[0][2]); print_r($TOTAL[0][3]); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346914 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 That's returning the same number on separate rows, like this: 2,984. 2,984. 2,984. 2,984. 2,984. 2,984. More than before, which was just a series of 2's Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346919 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 show me your current coding again. thx Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346920 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 Here it is in its entirity! (told you there was a lot!) :-) if ($supplier_name == "One") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2a * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30a * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesa * 12; $LOCAL_REDUCED = $local_line_details * $locala / 100; $NATIONAL_REDUCED = $national_line_details * $nationala / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonea / 100; $ORANGE_REDUCED = $orange_line_details * $orangea / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilea / 100; $O2_REDUCED = $o2_line_details * $o2a / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationala / 100; $OTHER_REDUCED = $other_line_details * $other_mobilea / 100; $TOTAL_REDUCED_1 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_1 = number_format($TOTAL_REDUCED_1, 2); } if ($supplier_name == "Two") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2b * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30b * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesb * 12; $LOCAL_REDUCED = $local_line_details * $localb / 100; $NATIONAL_REDUCED = $national_line_details * $nationalb / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoneb / 100; $ORANGE_REDUCED = $orange_line_details * $orangeb / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobileb / 100; $O2_REDUCED = $o2_line_details * $o2b / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalb / 100; $OTHER_REDUCED = $other_line_details * $other_mobileb / 100; $TOTAL_REDUCED_2 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_2 = number_format($TOTAL_REDUCED_2, 2); } if ($supplier_name == "Three") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2c * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30c * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesc * 12; $LOCAL_REDUCED = $local_line_details * $localc / 100; $NATIONAL_REDUCED = $national_line_details * $nationalc / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonec / 100; $ORANGE_REDUCED = $orange_line_details * $orangec / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilec / 100; $O2_REDUCED = $o2_line_details * $o2c / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalc / 100; $OTHER_REDUCED = $other_line_details * $other_mobilec / 100; $TOTAL_REDUCED_3 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_3 = number_format($TOTAL_REDUCED_3, 2); } if ($supplier_name == "Four") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2d * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30d * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesd * 12; $LOCAL_REDUCED = $local_line_details * $locald / 100; $NATIONAL_REDUCED = $national_line_details * $nationald / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoned / 100; $ORANGE_REDUCED = $orange_line_details * $oranged / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobiled / 100; $O2_REDUCED = $o2_line_details * $o2d / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationald / 100; $OTHER_REDUCED = $other_line_details * $other_mobiled / 100; $TOTAL_REDUCED_4 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_4 = number_format($TOTAL_REDUCED_4, 2); } if ($supplier_name == "Five") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2e * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30e * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linese * 12; $LOCAL_REDUCED = $local_line_details * $locale / 100; $NATIONAL_REDUCED = $national_line_details * $nationale / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonee / 100; $ORANGE_REDUCED = $orange_line_details * $orangee / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilee / 100; $O2_REDUCED = $o2_line_details * $o2e / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationale / 100; $OTHER_REDUCED = $other_line_details * $other_mobilee / 100; $TOTAL_REDUCED_5 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_5 = number_format($TOTAL_REDUCED_5, 2); } if ($supplier_name == "Sixl") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6, 2); } $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); print_r($TOTALS[0][0]); print_r($TOTALS[0][1]); print_r($TOTALS[0][2]); print_r($TOTALS[0][3]); print_r($TOTALS[0][4]); print_r($TOTALS[0][5]); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346921 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 thats nothing my development teams have pages over 1000 lines. easily. anyway, 1. what is $supplier_name. 2. try this... if ($supplier_name == "One") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2a * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30a * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesa * 12; $LOCAL_REDUCED = $local_line_details * $locala / 100; $NATIONAL_REDUCED = $national_line_details * $nationala / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonea / 100; $ORANGE_REDUCED = $orange_line_details * $orangea / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilea / 100; $O2_REDUCED = $o2_line_details * $o2a / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationala / 100; $OTHER_REDUCED = $other_line_details * $other_mobilea / 100; $TOTAL_REDUCED_1 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_1 = number_format($TOTAL_REDUCED_1); } if ($supplier_name == "Two") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2b * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30b * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesb * 12; $LOCAL_REDUCED = $local_line_details * $localb / 100; $NATIONAL_REDUCED = $national_line_details * $nationalb / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoneb / 100; $ORANGE_REDUCED = $orange_line_details * $orangeb / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobileb / 100; $O2_REDUCED = $o2_line_details * $o2b / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalb / 100; $OTHER_REDUCED = $other_line_details * $other_mobileb / 100; $TOTAL_REDUCED_2 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_2 = number_format($TOTAL_REDUCED_2); } if ($supplier_name == "Three") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2c * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30c * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesc * 12; $LOCAL_REDUCED = $local_line_details * $localc / 100; $NATIONAL_REDUCED = $national_line_details * $nationalc / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonec / 100; $ORANGE_REDUCED = $orange_line_details * $orangec / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilec / 100; $O2_REDUCED = $o2_line_details * $o2c / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalc / 100; $OTHER_REDUCED = $other_line_details * $other_mobilec / 100; $TOTAL_REDUCED_3 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_3 = number_format($TOTAL_REDUCED_3); } if ($supplier_name == "Four") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2d * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30d * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesd * 12; $LOCAL_REDUCED = $local_line_details * $locald / 100; $NATIONAL_REDUCED = $national_line_details * $nationald / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafoned / 100; $ORANGE_REDUCED = $orange_line_details * $oranged / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobiled / 100; $O2_REDUCED = $o2_line_details * $o2d / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationald / 100; $OTHER_REDUCED = $other_line_details * $other_mobiled / 100; $TOTAL_REDUCED_4 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_4 = number_format($TOTAL_REDUCED_4); } if ($supplier_name == "Five") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2e * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30e * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linese * 12; $LOCAL_REDUCED = $local_line_details * $locale / 100; $NATIONAL_REDUCED = $national_line_details * $nationale / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonee / 100; $ORANGE_REDUCED = $orange_line_details * $orangee / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilee / 100; $O2_REDUCED = $o2_line_details * $o2e / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationale / 100; $OTHER_REDUCED = $other_line_details * $other_mobilee / 100; $TOTAL_REDUCED_5 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_5 = number_format($TOTAL_REDUCED_5); } if ($supplier_name == "Sixl") { $ISDN2_REDUCED = $isdn2_line_details * $isdn2f * 12; $ISDN_THIRTY_REDUCED = $isdn30_channels_line_details * $isdn30f * 12; $ANALOGUE_LINES_REDUCED = $analogue_lines_line_details * $analogue_linesf * 12; $LOCAL_REDUCED = $local_line_details * $localf / 100; $NATIONAL_REDUCED = $national_line_details * $nationalf / 100; $VODAFONE_REDUCED = $vodafone_line_details * $vodafonef / 100; $ORANGE_REDUCED = $orange_line_details * $orangef / 100; $TMOBILE_REDUCED = $tmobile_line_details * $tmobilef / 100; $O2_REDUCED = $o2_line_details * $o2f / 100; $INTERNATIONAL_REDUCED = $international_line_details * $internationalf / 100; $OTHER_REDUCED = $other_line_details * $other_mobilef / 100; $TOTAL_REDUCED_6 = $OTHER_REDUCED + $INTERNATIONAL_REDUCED + $VODAFONE_REDUCED + $ORANGE_REDUCED + $TMOBILE_REDUCED + $O2_REDUCED + $NATIONAL_REDUCED + $LOCAL_REDUCED + $ANALOGUE_LINES_REDUCED + $ISDN_THIRTY_REDUCED + $ISDN2_REDUCED; $TOTAL_REDUCED_6 = number_format($TOTAL_REDUCED_6); } $TOTALS = array($TOTAL_REDUCED_1, $TOTAL_REDUCED_2, $TOTAL_REDUCED_3, $TOTAL_REDUCED_4, $TOTAL_REDUCED_5, $TOTAL_REDUCED_6); print_r($TOTALS[0][0]); print_r($TOTALS[0][1]); print_r($TOTALS[0][2]); print_r($TOTALS[0][3]); print_r($TOTALS[0][4]); print_r($TOTALS[0][5]); Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346922 Share on other sites More sharing options...
stualk Posted September 12, 2007 Author Share Posted September 12, 2007 Over 1000 lines? This is currently about 1,000 in total because it works in steps. This problem is with Step One so God help me with the rest! 1) supplier name is the name of the telecoms supplier that is offering the figures that we're putting in numerical order. 2) that code actually doesn't display anything at all for some strange reason! Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346929 Share on other sites More sharing options...
xyn Posted September 12, 2007 Share Posted September 12, 2007 1. how is the variable defined? Quote Link to comment https://forums.phpfreaks.com/topic/68998-arrays-grrrr/#findComment-346930 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.