I am having to sort an array of objects by an arbitrary object field name that you are not going to know in advance, therefore, I cannot name the sorting function accordingly nor reference the object accordingly:
class ResizeView extends View {
function displayHTML() {
$field = $safe->getField();
global $field;
$safe = null;
if (!$field) $field = 'image_name'; // DEFAULT FIELD NAME
usort($imageArray, array($this, 'field_name_sort'));
}
function field_name_sort(&$a, $b) {
global $field;
if ($a[???]->$field === $b[???]->$field) return 0;
return (strcmp(strtolower($a[???]->$field), strtolower($b->$field));
}
}
I am stuck. I can't pass the value of $field, which is required for the sorting to be dynamically possible according to the value of $field within the array of objects who happens to have an object property named the value of $field. How then can I sort my array of objects? The PHP manual offers no help for this at all since it doesn't involve anything LIKE this!
Thanx
Phil