|
|
|
| Title : |
A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array. |
| Categories : |
Algorithms, Arrays, PHP, Complete Programs |
 Petter Nilsen |
| Date : |
Jan 17th 1999 |
| Grade : |
2 of 5 (graded 8 times) |
| Viewed : |
12755 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Petter Nilsen |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
<?php
function bubblesort($a1,$a2)
{
for($i = sizeof($a1); $i >= 1; $i--)
{
for($j = 1; $j <= $i; $j++)
{
if($a1[$j-1] > $a1[$j])
{
$t = $a1[$j-1];
$t2 = $a2[$j-1];
$a1[$j-1] = $a1[$j];
$a2[$j-1] = $a2[$j];
$a1[$j] = $t;
$a2[$j] = $t2;
}
}
}
}
?>
|
|
| Browse a MySQL database & draw a tree view & load final items into a template page. Categories : MySQL, Complete Programs, Algorithms, PHP, Databases | | | A recursive function to traverse a multi-dimensional array where the
dimensions are not known Categories : Arrays, PHP, Algorithms | | | minus - subtract arrays. Send two arrays and get an array with the operation A-B, elements on A that are not included on B. Categories : PHP, Arrays, Algorithms | | | A class to put get and post variables in hidden form
elements. Works on scalars, normal arrays, associative
arrays. Categories : Algorithms, Variables, Arrays, PHP, PHP Classes | | | navbar.php3 - Dynamic hyperlinked navigation bars Categories : HTML and PHP, Arrays, PHP, Complete Programs | | | quick sort for associative arrays Categories : Algorithms, Arrays, PHP | | | PHP-MySQL shopping cart
Categories : PHP, Ecommerce, Complete Programs | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Functions to access a NNTP/NNRP newsserver. Complete set with examples is at ftp://ftp.nederland.net/pub/nnrplib Categories : Search, PHP, Complete Programs | | | phpCards - PHP/mySQL postcard script with web based admin to add, edit, and delete cards and categories. Very easy to install. Categories : PHP, Complete Programs, HTML and PHP, MySQL | | | clearing variables in php3 Categories : Variables, Arrays, PHP | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Select with current month Categories : PHP, HTML and PHP, Date Time, Arrays | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | PHP Random rss feeds - selects 49 random feeds from an unlimited list and displays them on your website. It's Ideal for those moments when you got 5 minutes and dont know which one of your feeds to read. Categories : PHP, Rich Site Summary (RSS), Arrays | |
| | | | igor petrov wrote :66
IMHO there is one mistake in 4-th line of the example
361.
for($i = sizeof($a1); $i >= 1; $i--)
should be like
for($i = sizeof($a1) - 1; $i >= 1; $i--)
| |
|
|
|