Abdul and The Arfan Theory
Lebih dari hari yang kemarin
Tuesday, March 03, 2009
sorting dengan usort di php
function cmp($a, $b)
{
if ($a->a == $b->a) {
return 0;
}
return ($a->a < $b->a) ? -1 : 1;
}
$ob1->a = 10;
$ob2->a = 2;
$ar = array($ob1, $ob2);
usort($ar, "cmp");
var_dump($ar);
//-- end of php code
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment