PHP Classes

File: swap.php

Recommend this page to a friend!
  Classes of Shibly   PHP Array Sort Algorithms class   swap.php   Download  
File: swap.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP Array Sort Algorithms class
Sort arrays values using multiple algorithms
Author: By
Last change: Update of swap.php
Date: 2 months ago
Size: 580 bytes
 

Contents

Class file image Download
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/*
function array_swap($array, $key1 = 0, $key2 = 1)
{
    $newArray = array();
    foreach ($array as $key => $val) {
        if ($key == $key1) {
            $newArray[$key1] = $array[$key2];
        } else if ($key == $key2) {
            $newArray[$key2] = $array[$key1];
        } else {
            $newArray[$key] = $val;
        }
    }
    return $newArray;
}

*/
$input = array("red", "green", "blue", "yellow");
$res = array_splice($input, 3);
print_r($res);
?>