note 57233 deleted from ref.array by aidan
| From: | aidan@php.net | Date: | Sun, 09 Oct 2005 09:10:58 +0000 |
| Subject: | note 57233 deleted from ref.array by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96722@lists.php.net to get a copy of this message | ||
Note Submitter: Powl
----
<?php
function array_move_by_value ($array, $tbl, $position, $value){
foreach ($array[$tbl] as $key => $val) {
if ($val == $value){
if ($key == $position) return $array;
$array[$tbl][$key] = $array[$tbl][$position];
$array[$tbl][$position] = $value;
return $array;
}
}
}
$test_array = array('test' => array( 'arr1', 'arr2',
'arr3' ),
);
$test_array = array_move_by_value( $test_array, 'test', '0','arr3' );
print_r ($test_array);
?>