Bubble Sort in array in php
<?php
function bubble_Sort($my_array )
{
do
{
$swapped = false;
for( $i = 0, $c = count( $my_array ) - 1; $i < $c; $i++ )
{
if( $my_array[$i] > $my_array[$i + 1] )
{
list( $my_array[$i + 1], $my_array[$i] ) =
array( $my_array[$i], $my_array[$i + 1] );
$swapped = true;
}
}
}
while( $swapped );
return $my_array;
}
$test_array = array(3, 0, 2, 5, -1, 4, 1);
echo "Original Array :\n";
echo implode(', ',$test_array );
echo "\nSorted Array\n:";
echo implode(', ',bubble_Sort($test_array)). PHP_EOL;
?>
Also in PHP:
- $tmpmembershipfee = MembershipFee::orderBy('created_at','DESC') ->first();
- detectar comienzo cadena php
- all words capital php
- WordPress Creating “startupl” folder and Wrtting to .htaccess
- centos php log
- Allowed memory size of 536870912 bytes exhausted (tried to allocate 264245248 bytes) http://localhost:8000/createProduct
- codeigniter device
- curlopt_postfields php example
- check key in array php
- disable notice php in runtime
- console.log() but with php
- create migration table in php
- disable base64 decode php.ini
- check if a word in string php
- confirm popup laravel
- add date days php
- error show php
- daye in php
- In Connection.php line 664:SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema
- check variable data type with value in php
- date time from timestamp php
- July 2, 2019 php date format
- check on off in php code
- clear the saved cache of my laravel websitefor all the users