I have a conditional that gives my array the value of 2 if its empty otherwise the value will be 1, what I want is to sort this bidimensinal by the value of the associative index for example
$arr[$n]["key"] = 1;
$arr[$n]["key"] = 1;
$arr[$n]["key"] = 1;
$arr[$n]["key"] = 2;
$arr[$n]["key"] = 2;
What I want to do is first print the number 1's and then the number 2's
I've tried all the methods on this page and nothing works.. please help me. Thanks!
You can just sort your array with asort, quick example:
<?php
$arr[0][1] = 1;
$arr[0][2] = 1;
$arr[0][3] = 2;
$arr[0][4] = 2;
$arr[0][5] = 1;
asort($arr[0]);
var_dump($arr[0]);
Then you can foreach sort this array with a loop;
There is a very cool table to choose the function for the excepted result: