/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * * EXAMPLE #1 * * sort array of objects based on specified attribute values * in this case "lastname", followed by "firstname" * **/ echo "Before"; echo "<pre>"; echo "</pre>"; echo "<br /><br />"; function alpha_sort($a, $b) { if ($a->lastname == $b->lastname) { } } echo "After"; echo "<pre>"; echo "</pre>"; ?> <?php /** * * EXAMPLE #2 * * sort array of arrays based on specified array keys * in this case "lastname", followed by "firstname" * **/ ); function alpha_sort($a, $b) { if ($a['lastname'] == $b['lastname']) { } } echo "<pre>"; echo "</pre>"; ?>