note 117532 added to array.sorting

From: Date: Thu, 25 Jun 2015 06:57:49 +0000
Subject: note 117532 added to array.sorting
Groups: php.notes 
Request: Send a blank email to php-notes+get-202946@lists.php.net to get a copy of this message
// takes an array and desired key value and returns an array // searches through an array for a given key, if found the key that row is made the first row and the other rows are inserted accordingly. // the facility of this function is to get the value with a specific key of an array as the first value. /////////////////////////////// function starts ////////////////////////////// function dksort($array, $case){ if(array_key_exists($case,$array)){ $a[$case] = $array[$case]; foreach($array as $key=>$val){ if($case==$key){ }else{ $a[$key] = $array[$key]; } } } return $a; } $d = array( '22'=>'jdfhgjfd', '33'=>'jdfhgjfd', '11'=>'jrtyrjfd', '55'=>'jrtydairjfd', '77'=>'jopo', '99'=>'jrtasajfd', '44'=>'jopasdwo', '88'=>'hdgatyuyuiuy' ); $c = dksort($d, '55'); print_r($c); ////////////////////////// function ends //////////////////////////////////////// ---- Server IP: 72.52.91.14 Probable Submitter: 202.5.50.43 ---- Manual Page -- http://php.net/manual/en/array.sorting.php Edit -- https://master.php.net/note/edit/117532 Del: integrated -- https://master.php.net/note/delete/117532/integrated Del: useless -- https://master.php.net/note/delete/117532/useless Del: bad code -- https://master.php.net/note/delete/117532/bad+code Del: spam -- https://master.php.net/note/delete/117532/spam Del: non-english -- https://master.php.net/note/delete/117532/non-english Del: in docs -- https://master.php.net/note/delete/117532/in+docs Del: other reasons-- https://master.php.net/note/delete/117532 Reject -- https://master.php.net/note/reject/117532 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202946) next »