So we got the values (INT) :
V1 , V2 , V3 , V4
And the text :
Text1 , Text2 , Text3 , Text4
We will order the values and echo corespondent Text instead of values.
Let’s take an example :
(variables) : V1 = 1 , V2 = 30 , V3 = 2 , V4 = 4
(text) : Banana , Cake , Apple , Patato
Will result ->
V1 , V3 , V4 , V2
after they are ordered but we will display text instead of our current result .
So the final echo is :
Banana , Apple , Patato , Cake . (will echo them into a table)
Note : Some of the values can be equal !
So far i tried with 3 arrays :
($text_array) text , ($arr1) V1[...] , and ($arr2) V1[...]
(same as second because I use sort($array); on it).
I tried to echo with :
echo $text_array[array_search($arr1[0], $arr2)];
but this will make the text repeat if values are the same.
I am sorry if I did not make myself clear … it’s really hard to explain.
#
UPDATE
#
It looks like this :
$V1 = $vars[1] + $vars[29] + $vars[30];
$V2 = $vars[6] + $vars[19] + $vars[40];
$V3 = $vars[14] + $vars[15] + $vars[44];
$V4 = $vars[0] + $vars[22] + $vars[37];
..........................................
$V15 = $vars[3] + $vars[28] + $vars[31];
Text array :
$valori = array(("Altruismul", "Simtul estetic", "Creativitatea", "Stimularea intelectuala", "Reusita obiectivata", "Independenta", "Prestigiul", "Conducerea altora", "Avantajele materiale", "Siguranta", "Ambianta de la locul de munca", "Relatiile cu superiorii", "Relatiile cu colegii", "Stilul de viata pe care-l asigura profesia", "Varietate");
Tried :
$arr = array("Altruismul" => $V1 , "Simtul estetic" => $V2 , "Creativitatea" => $V3 , "Stimularea intelectuala" => $V4 , "Reusita obiectivata" => $V5 , "Independenta" => $V6 , "Prestigiul" => $V7 , "Conducerea altora" => $V8 , "Avantajele materiale" => $V9 , "Siguranta" => $V10 , "Ambianta de la locul de munca" => $V11 , "Relatiile cu superiorii" => $V12 , "Relatiile cu colegii" => $V13 , "Stilul de viata pe care-l asigura profesia" => $V14 , "Varietate" => $V15);
asort($arr);
Did not work well.
I’m guessing what you’re trying to say is that you have two arrays that are linked, and you want to sort one and use that sorting to output the second. If so, try this:
Or alternatively: