selection sort - 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 selection sort.php
- <?php
- $values= array(1,4,10,3,30,14,5);
- $size = count($values);
- /*
- function display($array) {
- $total = count($array);
- foreach($array as $key => $valeur) {
- if($key == ($total - 1))
- {
- echo("$valeur");
- }
- else
- {
- echo("$valeur, ");
- }
- }
- }
- echo("valeur non triee : ");
- display($values);
- */
- for($i=0;$i<=$size;$i++)
- {
- for($j=$i+1;$j<=$size;$j++)
- {
- if($values[$j] < $values[$i])
- {
- $min = $values[$j];
- $values[$j] = $values[$i];
- $values[$i] = $min;
- }
- }
- echo(", $values[$i]");
- }
File Description
- selection sort
- PHP Code
- 11 Jan-2021
- 604 Bytes
You can Share it:
Latest PHP Pastes