i have an associative array with two keys
$miarray = array(
array('factor' => $textof[1], 'valor' => $i1),
array('factor' => $textof[2], 'valor' => $i2),
array('factor' => $textof[3], 'valor' => $i3),
array('factor' => $textof[4], 'valor' => $i4),
array('factor' => $textof[5], 'valor' => $i5),
array('factor' => $textof[6], 'valor' => $i6),
array('factor' => $textof[7], 'valor' => $i7),
array('factor' => $textof[8], 'valor' => $i8),
array('factor' => $textof[9], 'valor' => $i9),
array('factor' => $textof[10], 'valor' => $i10),
);
the first key has text and the second key has numeric values. i want to order the array by de second key in ascending order and the add each pair to a variable that will be echoed at the end of the php file.
to sort i use the following
array_multisort(array_column($miarray, 'valor'), SORT_ASC, $miarray);
and to access each pair
foreach ($miarray as $optionArray){
$pr .="$optionArray[\"factor\"] - $optionArray[\"valor\"]<br>";
}
nevertheless i get error
[20-Nov-2018 17:58:54 UTC] PHP Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in xxxxxxxxxxxxxxxxx
i have seen many examples but all use print to show the resulting array. thanks for helping.