teoo315

Members

7

0 Neutral

• Rank
Newbie
1. bidimensional array issue

Thank you, now everything works perfectly
2. bidimensional array issue

Now it's more cleary, but if i try your code: \$z=0;\$countLow=0;\$fissoLow=0;\$res = array();for (\$i=0;\$i<10; \$i++){ \$z+=2; \$fissoLow = 10*2*\$z; \$countLow = \$fissoLow*\$z; \$res['fissi'][] = \$fissoLow; \$res['conteggi'][] = \$countLow;}\$f = max(\$res['conteggi']);\$c = \$res['fissi'][array_search(\$f, \$res, TRUE)];echo "f should be 8000 =>" . \$f . " c should be 400 =>". \$c; This is the output: f should be 8000 =>8000 c should be 400 =>40 There is a problem with \$c as you can see, but i don't know why.It seems right the function array_search...
3. bidimensional array issue

This is the logical process i'm trying to coding: Create an array "res" of two arrays called "fissi" and "conteggi" and populate it.Find the maximum value of array "conteggi"Find the matching value of array "fissi" inside array "res"Save this values into \$c and \$f For example: Array "conteggi"; (40, 80, 120, 160, 200, 240, 280, 320, 360, 400)Array "fissi"; (80, 320, 720, 1280, 2000, 2880, 3920, 5120, 6480, 8000)Array "res"; :[0] 40 80[1] 80 320[2] 120 720[3] 160 1280[4] 200 2000[5] 240 2880[6] 280 3920[7] 320 5120[8] 360 6480[9] 400 8000Max of "conteggi" = 8000 with key=[9] then\$c = 8000\$f =
4. bidimensional array issue

Yeah you're right. Now everything seems working fine. One last thing, do you confirm that the process to find max of \$res is suitable? Thx man
5. bidimensional array issue

Ok great!I fixed for cycle and now it look like this: for (\$i=0;\$i<count(\$res); \$i++){\$max = max(\$res[\$i]['contegg']);echo \$max . " ";} Output: 80 320 720 1280 2000 2880 3920 5120 6480 8000 Notation: I inserted "echo \$max" inside for cycle, only to see the change of values. I think it should be correct. Is not? And now last but not least for cycle to show \$res 2D array: for (\$j=0; \$j<count(\$res); \$j++){echo \$res['fiss'][\$j] . " " . \$res[\$j]['contegg'] . "<br />";} Output: ArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
6. bidimensional array issue

It works the first part But i can't show the values. What's the right syntax? Sorry but i'm a newbie with php and programming. Again, if i want to find the max value of array "conteggi", what's the right way? I'm trying with this: \$max = max(\$res["conteggi"]);echo \$max; But doesn't work: Warning: max() : When only one parameter is given, it must be an array in on line 13
7. bidimensional array issue

Hi everybody,it's been a couple of days that i'm trying to show the values inside a multidimensional array but unsuccessfully. This is my code: \$i=0;\$countLow=0;\$fissoLow=0;for (\$i=0;\$i<10; \$i++){ \$z+=2; \$fissoLow = 10*2*\$z; \$countLow = \$fissoLow*\$z; \$res=array("fissi" => array(\$fissoLow),"conteggi" => array(\$countLow)); }for (\$j=0; \$j<count(\$res); \$j++){ echo \$res['fissi'][\$j] . " " . \$res['conteggi'][\$j] . "<br />"; } And this is the (wrong) result: 400 8000 This should be the last row of \$res array, not the only one. Waiting your replies
×
×
• Create New...