0

I have three arrays that I want to print out with a nice sorting.

$person[]->name ('Foo','Bar','Foooo')
$person[]->sold ('10000','123123','234234')
$person[]->comment ('asd','qwer','zxcv')

Now I print out every array like this:

$total = 3;
$x = 0;
while($x<$total)
{
echo $person[$x]->name;
echo $person[$x]->sold;
echo $person[$x]->comment;
$x++;
}

This returns the content of the arrays. Actually I print out this in a table, but that doesn't make any difference.

My question is if it's possible to print out the arrays and order by $person->sold for example? If yes - how?

Many thanks!

2
  • The Answer you need is allready given in: stackoverflow.com/questions/7814420/… Commented Oct 30, 2014 at 10:44
  • I would start by grouping them together by person rather then by type: $arrperson = get_object_vars($person); array_unshift($arrperson, NULL); $easierperson = call_user_func_array('array_map',$arrperson); Then it's just an usort. Commented Oct 30, 2014 at 11:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.