Horje
php bubble sort Code Example
php bubble sort
<?php 
// PHP program for implementation 
// of Bubble Sort
  
function bubbleSort(&$arr)
{
    $n = sizeof($arr);
  
    // Traverse through all array elements
    for($i = 0; $i < $n; $i++) 
    {
        // Last i elements are already in place
        for ($j = 0; $j < $n - $i - 1; $j++) 
        {
            // traverse the array from 0 to n-i-1
            // Swap if the element found is greater
            // than the next element
            if ($arr[$j] > $arr[$j+1])
            {
                $t = $arr[$j];
                $arr[$j] = $arr[$j+1];
                $arr[$j+1] = $t;
            }
        }
    }
}
  
// Driver code to test above
$arr = array(64, 34, 25, 12, 22, 11, 90);
  
$len = sizeof($arr);
bubbleSort($arr);
  
echo "Sorted array : \n";
  
for ($i = 0; $i < $len; $i++)
    echo $arr[$i]." "; 
  
// This code is contributed by ChitraNayal.
?>




Php

Related
install bcmath php 7.3 ubuntu Code Example install bcmath php 7.3 ubuntu Code Example
echo php in html Code Example echo php in html Code Example
acf create post with fields Code Example acf create post with fields Code Example
set names utf8 Code Example set names utf8 Code Example
Extract all audio tracks / streams Code Example Extract all audio tracks / streams Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8