Sort By State - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Sort By State.php
- <?php
- $omni = array(
- array(
- 'id' => 17760,
- 'name' => array(
- 'long' => 'Omni Military Loans in Columbus, GA.',
- 'abbv' =>'Columbus, GA'
- )
- ),
- array(
- 'id' => 21037,
- 'name' => array(
- 'long' => 'Omni Military Loans in El Paso, TX.',
- 'abbv' =>'El Paso, TX'
- )
- ),
- array(
- 'id' => 21040,
- 'name' => array(
- 'long' => 'Jacksonville, FL',
- 'abbv' =>'Jacksonville, FL'
- )
- ),
- array(
- 'id' => 21040,
- 'name' => array(
- 'long' => 'Omni Military Loans in Hinesville, GA.',
- 'abbv' =>'Hinesville, GA'
- )
- )
- );
- function compare($a, $b)
- {
- return strcmp(substr($a["name"]["abbv"],-2), substr($b["name"]["abbv"],-2));
- }
- usort($omni, "compare");
- print_r($omni);