Search Results

Search found 15007 results on 601 pages for 'array'.

Page 6/601 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Need to sort 3 arrays by one key array

    - by jeff6461
    I am trying to get 3 arrays sorted by one key array in objective c for the iphone, here is a example to help out... Array 1 Array 2 Array 3 Array 4 1 15 21 7 3 12 8 9 6 7 8 0 2 3 4 8 When sorted i want this to look like Array 1 Array 2 Array 3 Array 4 1 15 21 7 2 3 4 8 3 12 8 9 6 7 8 0 So array 2,3,4 are moving with Array 1 when sorted. Currently i am using a bubble sort to do this but it lags so bad that it crashes by app. The code i am using to do this is int flag = 0; int i = 0; int temp = 0; do { flag=1; for(i = 0; i < distancenumber; i++) { if(distance[i] > distance[i+1]) { temp = distance[i]; distance[i]=distance[i + 1]; distance[i + 1]=temp; temp = FlowerarrayNumber[i]; FlowerarrayNumber[i] = FlowerarrayNumber[i+1]; FlowerarrayNumber[i + 1] = temp; temp = BeearrayNumber[i]; BeearrayNumber[i] = BeearrayNumber[i + 1]; BeearrayNumber[i + 1] = temp; flag=0; } } }while (flag==0); where distance number is the amount of elements in all of the arrays, distance is array 1 or my key array. and the other 2 are getting sorted. If anyone can help me get a merge sort(or something faster, it is running on a iPhone so it needs to be quick and light) to do this that would be great i cannot figure out how the recursion works in this method and so having a hard time to get the code to work. Any help would be greatly appreciated

    Read the article

  • how to sort a multidemensional array by an inner key

    - by Derek Vance
    i have this enormous array that i am pulling from an API for BattleField Bad Company 2, and the soldier stats can be pulled as a multi dimensional array with an inner array for each soldier, however the API sormats it sorting the soldiers by name alphabetically, i want to sort them by rank (which is just another key within that soldiers array). ive been trying to figure this out for days, anyone have any ideas? (ie sort the array by $arr[players][][rank] here is a bit of the array Array ( [players] = Array ( [0] = Array ( [name] = bigjay517 [rank] = 29 [rank_name] = SECOND LIEUTENANT II [veteran] = 0 [score] = 979440 [level] = 169 [kills] = 4134 [deaths] = 3813 [time] = 292457.42 [elo] = 319.297 [form] = 1 [date_lastupdate] = 2010-03-30T14:06:20+02:00 [count_updates] = 13 [general] = Array ( [accuracy] = 0.332 [dogr] = 86 [dogt] = 166 [elo0] = 309.104 [elo1] = 230.849 [games] = 384 [goldedition] = 0 [losses] = 161 [sc_assault] = 146333 [sc_award] = 567190 [sc_bonus] = 35305 [sc_demo] = 96961 [sc_general] = 264700 [sc_objective] = 54740 [sc_recon] = 54202 [sc_squad] = 53210 [sc_support] = 70194 [sc_team] = 21215 [sc_vehicle] = 44560 [slevel] = 0 [spm] = 0 [spm0] = 0 [spm1] = 0 [srank] = 0 [sveteran] = 0 [teamkills] = 67 [udogt] = 0 [wins] = 223 )

    Read the article

  • foreach loop corrupting my array?

    - by WmasterJ
    Explanation I have a multidimensional array that is iterated over to created a categorized view of people with different research interests. The main array look something like this: Array ( ... ['Cell Biology'] => Array(4 elements) ['Molecular'] => Array(6 elements) ['Biology Education'] => Array(14 elements) ['Plant Biology'] => Array(19 elements) <--- Last element in array ) I know that the entire array is intact and correctly structured. The only information that is inside these array is an user id, like so: Array ('Plant Biology') 19 elements ( [0] => 737 [1] => 742 [2] => 748 ... ) My problem is that after i run the main array through a foreach loop the last 'sub-array' gets messed up. By messed up I mean that what you see about instead look like: String (13 characters) 'Plant Biology' This is without doing at all anything inside the loop with to the array that gets corrupted. Any tips to what it might be? PHP Code // ---> Array is OK here echo "<h2>Research divided</h2>"; // Loop areas and list them in 2 columns foreach($research['areas'] as $area => $areaArray) { // ---> Here it is already corrupted $count = count($areaArray); if($count > 0) { echo "<h3>$area</h3><hr/>"; echo "<table class='area_list'><tr>"; // Loop users within areas, divided up in 2 columns for($i=0 ; $i<$count ; $i++) { $uid = $areaArray[$i]; echo "<li>$uid</li>"; } echo "</tr></table>"; } }

    Read the article

  • c# Multi diemention (array, arraylist, or hashtable) ?

    - by Data-Base
    hello, I'm trying to figure out how to build a multi dimensional "array" that is: flexible size use 2 keys 1st key is int (flexible) 2nd key is string (kind of limited) the use will be like console.writelen(array[0]["firstname"]); console.writelen(array[0]["lastname"]); console.writelen(array[0]["phone"]); console.writelen(array[1]["firstname"]); console.writelen(array[1]["lastname"]); console.writelen(array[1]["phone"]); ..... ..... console.writelen(array[x]["firstname"]); console.writelen(array[x]["lastname"]); console.writelen(array[x]["phone"]); something like this

    Read the article

  • PHP : flatten array - fastest way?

    - by Industrial
    Is there any fast way to flatten an array and select subkeys ('key'&'value' in this case) without running a foreach loop, or is the foreach always the fastest way? Array ( [0] => Array ( [key] => string [value] => a simple string [cas] => 0 ) [1] => Array ( [key] => int [value] => 99 [cas] => 0 ) [2] => Array ( [key] => array [value] => Array ( [0] => 11 [1] => 12 ) [cas] => 0 ) ) To: Array ( [int] => 99 [string] => a simple string [array] => Array ( [0] => 11 [1] => 12 ) )

    Read the article

  • Why I lose certain values from array?

    - by blankon91
    I've the code to input the values dynamically, when I use it to add the values for the first time, it's fine, but when I want to edit it, the old values didn't inserted on sql query but the new values inserted Here is the example: http://i.stack.imgur.com/dwugS.jpg here is the code: ============the function================= sub ShowItemfgEdit(query,selItemName,defValue,num,cdisable) response.write "<select " & cdisable & " num=""" & num & """ id=""itemCombo"" name=""" & selItemName & """ class=""label"" onchange=""varUsage.ChangeSatuanDt(this)"">" if NOT query.BOF then query.moveFirst WHILE NOT query.EOF tulis = "" if trim(defValue) = trim(query("ckdbarang")) then tulis = "selected" end if response.write "<option value=""" & trim(query("ckdbarang")) & """" & tulis & ">" & trim(query("ckdbarang")) & " - " & trim(query("vnamabarang")) query.moveNext WEND end if response.write "</select>" end sub ============calling the function================ <td class="rb" align="left"><% call ShowItemfgEdit(qGetItemfgGrp,"fitem",qGetUsageDt("ckdfg"),countLine,readonlyfg) %></td> ==============post the value====================== <input type="hidden" name="fitem" value=""> ================get the value=================== for i = 1 to request.form("hdnOrderNum") if request.form("selOrdItem_" & i) <> "" then 'bla...blaa...blaa... ckdfg = trim(request.form("fitem_" & i)) '<==here is the problem objCommand.commandText = "INSERT INTO IcTrPakaiDt " &_ "(id, id_h, ckdunitkey, cnopakai, dtglpakai, ckdbarang, ckdgudang, nqty1, nqty2, csatuan1, csatuan2, nqtypakai, csatuanpakai, vketerangan, cJnsPakai, ckdprodkey, ckdfg, ncountstart, ncountstop, ncounttotal) " &_ " VALUES " &_ " (" & idDt & ",'" & idHd & "','" & selLoc & "','" & nopakai & "','" & cDate(request.form("hdnUsageDate")) & "','" & trim(ckdbarang) & "','" & trim(ckdgudang) & "'," & nqty1 & "," & nqty2 & ",'" & trim(csatuan1) & "','" & trim(csatuan2) & "'," & nqtypakai & ",'" & csatuanpakai & "','" & trim(keteranganItem) & "','" & trim(cjnspakai) & "','" & ckdprodkey & "','" &ckdfg& "'," & cnt1 & "," & cnt2 & "," & totalcnt & ")" set qInsertPakaiDt = objCommand.Execute end if next problem: old value of ckdfg didn't inserted to query, but the new value inserted. How to fix this bug?

    Read the article

  • Combining array values in multilevel array

    - by James Huckabone
    I have an array like so: array( 'a'=>array( 'a'=>3, 'f'=>5, 'sdf'=>0), 't'=>array( 'a'=>1, 'f'=>2, 'sdf'=>5), 'pps'=>array( 'a'=>1, 'f'=>2, 'sdf'=>3) ); Notice how the sub-arrays are the same for each top-level array. If I wanted to, what's the easiest way to combine the sub-arrays so that I'm left with a one-dimensional array like: array( 'a'=>5, 'f'=>9, 'sdf'=>8 );

    Read the article

  • Slow parity initialization of RAID-5 array on HP Smart Array 411 controller

    - by Rob Nicholson
    On 29th October 2011, I built a RAID-5 array using 4 x 146.8GB Seagate SAS ST3146855SS drives running at 15k connected to a PowerEdge R515 with HP Smart Array P411 controller running Windows 2008 (so nothing particularly unusual). I know that parity initialisation of a RAID-5 array can take some time but it's still running after 2.5 weeks which seems a little unusual. I'd previously built another array on the same controller using 4 x 2TB SATA-2 drives and that did take a while to complete but a) I'm sure it was less than 2.5 weeks, b) that array was ~12 times bigger and c) during initialization, the percentrage slowly increased each day. At the moment, the status display for this new 2nd array simply says "Parity Initialization Status: In Progress" and it's said that since the start. It's this lack of change on the status that worries me the most - feels like it's not actually doing anything. Do you think something has gone wrong or am I being unpatient and for some reason, the status not increasing is normal? I kind of expected a much smaller array on faster drives (15k SAS versus 7.5k SATA-2) to build in a few days. This is our primary SAN running StarWind so my "have a play" options are very limited. This 2nd array is currently in use for one small virtual disk so I could shut the target machine down, move the virtual disk to another drive and try rebuilding.

    Read the article

  • PHP Function needed for GENERIC sorting of a recordset array

    - by donbriggs
    Somebody must have come up with a solution for this by now. I wrote a PHP class to display a recordset as an HTML table/datagrid, and I wish to expand it so that we can sort the datagrid by whichever column the user selects. In the below example data, we may need to sort the recordset array by Name, Shirt, Assign, or Age fields. I will take care of the display part, I just need help with sorting the data array. As usual, I query a database to get a result, iterate throught he result, and put the records into an assciateiave array. So, we end up with an array of arrays. (See below.) I need to be able to sort by any column in the dataset. However, I will not know the column names at design time, nor will I know if the colums will be string or numeric values. I have seen a ton of solutions to this, but I have not seen a GOOD and GENERIC solution Can somebody please suggest a way that I can sort the recordset array that is GENERIC, and will work on any recordset? Again, I will not know the fields names or datatypes at design time. The array presented below is ONLY an example. Array ( [0] = Array ( [name] = Kirk [shrit] = Gold [assign] = Bridge ) [1] => Array ( [name] => Spock [shrit] => Blue [assign] => Bridge ) [2] => Array ( [name] => Uhura [shrit] => Red [assign] => Bridge ) [3] => Array ( [name] => Scotty [shrit] => Red [assign] => Engineering ) [4] => Array ( [name] => McCoy [shrit] => Blue [assign] => Sick Bay ) )

    Read the article

  • Adding an Array inside an array in a PHP function

    - by bateman_ap
    I have created a function in PHP that calls a webservice and parses through the result, assinging values to variables and returning them all as an Array. This all works perfectly, however I have come across a need to have an "array within my array" I am assigning values as below: $productName = $product->Name; $productID = $product->ID; $productArray = array( 'productName' => "$productName", 'productID' => "$productID" ); return $productArray; However I now have a piece of data that comes back with multiple results so I need to have a additional array to store these, I am getting the values from the returned XML using a foreach loop, however I want to be able to add them to the array with a name so I can reference them in the returned data, this is where I have a problem... $bestForLists = $product->BestFors; foreach( $bestForLists as $bestForList ) { $productBestFors = $bestForList->BestFor; foreach( $productBestFors as $productBestFor ) { $productBestForName = $productBestFor->Name; $productBestForID = $productBestFor->ID; } } I tried creating an array for these using the below code: $bestForArray[] = (array( "productBestForID" => "$productBestForID", "productBestForName" => "$productBestForName" )); And then at the end merging these together: $productArray= array_merge($productArray,$bestForArray); If I print out the returned value I get: Array ( [productName] => Test Product [productID] => 14128 [0] => Array ( [productBestForID] => 56647 [productBestForName] => Lighting ) [1] => Array ( [productBestForID] => 56648 [productBestForName] => Sound ) ) I would like to give the internal Array a name so I can reference it in my code, or is there a better way of doing this, at the moment I am using the following in my PHP page to get values: $productName = $functionReturnedValues['productName']; I would like to use the following to access the array I could then loop through: $bestForArray = $functionReturnedValues['bestForArray']; Hope someone can help

    Read the article

  • How to combine these two PHP arrays ?

    - by Annan
    I have two arrays in php that are part of an image management system. weighted_images A multidimensional array. Each sub array is an associative array with keys of 'weight' (for ordering by) and 'id' (the id of the image). array( 156 => array('weight'=>1, 'id'=>156), 784 => array('weight'=>-2, 'id'=>784), ) images This array is user input. It's an array of image ids. array(784, 346, 748) I want to combine them in to a single array of ids ordered by the weight of the image. If an image doesn't have a weight append to the end. It's not a particularly hard problem however my solution is far from elegant and can't help thinking that there must be a better way to do this. $t_images = array(); foreach ($weighted_images as $wi) { if ( in_array($wi['id'], $images) ) { $t_images[$wi['weight']] = $wi['id']; } } foreach ($images as $image) { if ( !$weighted_images[$image] ) { $t_images[] = $image; } } $images = $t_images; Question: Is there a better way to do this?

    Read the article

  • How to sort a multidimensional array by a certain key?

    - by Eelke
    This should be really simple, but what is the way to go on this. I want to sort an multidimensional array by a key, like this: Array ( [0] => Array ( [iid] => 1 [invitee] => 174 [nid] => 324343 [showtime] => 2010-05-09 15:15:00 [location] => 13 [status] => 1 [created] => 2010-05-09 15:05:00 [updated] => 2010-05-09 16:24:00 ) [1] => Array ( [iid] => 1 [invitee] => 220 [nid] => 21232 [showtime] => 2010-05-09 15:15:00 [location] => 12 [status] => 0 [created] => 2010-05-10 18:11:00 [updated] => 2010-05-10 18:11:00 )) Say i want to sort this by [status], how would I achieve this? Thanks in advance!

    Read the article

  • All possibilities in 2d array

    - by valli-R
    I have this array: $array = array ( array('1', '2', '3'), array('!', '@'), array('a', 'b', 'c', 'd'), ); And I want to know all character combination of sub arrays.. for example : 1!a 1!b 1!c 1!d 1@a 1@b 1@c 1@d 2!a 2!b 2!c 2!d 2@a 2@b ... Currently I am having this code : for($i = 0; $i < count($array[0]); $i++) { for($j = 0; $j < count($array[1]); $j++) { for($k = 0; $k < count($array[2]); $k++) { echo $array[0][$i].$array[1][$j].$array[2][$k].'<br/>'; } } } It works, but I think it is ugly, and when I am adding more arrays, I have to add more for. I am pretty sure there is a way to do this recursively, but I don't know how to start/how to do it. A little help could be nice! Thanks you!

    Read the article

  • Anyone Know a Great Sparse One Dimensional Array Library in Python?

    - by TheJacobTaylor
    I am working on an algorithm in Python that uses arrays heavily. The arrays are typically sparse and are read from and written to constantly. I am currently using relatively large native arrays and the performance is good but the memory usage is high (as expected). I would like to be able to have the array implementation not waste space for values that are not used and allow an index offset other than zero. As an example, if my numbers start at 1,000,000 I would like to be able to index my array starting at 1,000,000 and not be required to waste memory with a million unused values. Array reads and writes needs to be fast. Expanding into new territory can be a small delay but reads and writes should be O(1) if possible. Does anybody know of a library that can do it? Thanks!

    Read the article

  • How to add values in multidimensional array?

    - by vaiji
    I have a array like the bellow. Array ( [1] => Array ( [TotalPosts] => 46 [AgentSchemeNumber] => 11 [AgentName] => Vaiji ) [2] => Array ( [TotalPosts] => 3 [AgentSchemeNumber] => 22 [AgentName] => Vaiji ) [3] => Array ( [TotalPosts] => 0 [AgentSchemeNumber] => 33 [AgentName] => Vicky ) [4] => Array ( [TotalPosts] => 0 [AgentSchemeNumber] => 44 [AgentName] => Raja ) [5] => Array ( [TotalPosts] => 18 [AgentSchemeNumber] => 55 [AgentName] => Rama ) [6] => Array ( [TotalPosts] => 13 [AgentSchemeNumber] => 66 [AgentName] => Udaya ) ) Here AgentName vaiji contain 2 records. I want a output like Array ( [1] => Array ( [TotalPosts] => 49 [AgentSchemeNumber] => 11 or 22 (any number) [AgentName] => Vaiji ) [2] => Array ( [TotalPosts] => 0 [AgentSchemeNumber] => 33 [AgentName] => Vicky ) [3] => Array ( [TotalPosts] => 0 [AgentSchemeNumber] => 44 [AgentName] => Raja ) [4] => Array ( [TotalPosts] => 18 [AgentSchemeNumber] => 55 [AgentName] => Rama ) [5] => Array ( [TotalPosts] => 13 [AgentSchemeNumber] => 66 [AgentName] => Udaya ) ) Please help me how to do it?

    Read the article

  • "Simple" sort a nested array using array_multisort or native PHP functions instead of my own foreach loop

    - by Ana Ban
    I have the following array of days of the week, with each day having hours of the day (the whole array represents the schedule of a part-time employee): Array ( [7] => Array ( [0] => 15 [1] => 14 [2] => 13 [3] => 11 [4] => 12 [5] => 10 ) [1] => Array ( [0] => 10 [1] => 13 [2] => 12 ) [6] => Array ( [0] => 14 ) [3] => Array ( [0] => 4 [1] => 5 [2] => 6 ) ) and I simply need to: sort asc each sub-array (2nd dimension) - no need to maintain the numeric keys, values are integers sort asc the 1st dimension and maintain the numeric, integer keys ie: Array ( [1] => Array ( [0] => 10 [1] => 12 [2] => 13 ) [3] => Array ( [0] => 4 [1] => 5 [2] => 6 ) [6] => Array ( [0] => 14 ) [7] => Array ( [0] => 10 [1] => 11 [2] => 12 [3] => 13 [4] => 14 [5] => 15 ) ) Additional info: only the keys of the 1st dimension and the values of the 2nd dimension (and of course their association) are meaningful to my use-case the 1st dimension can have at most 7 values, ranging from 1-7 (days of the week), and will have at least 1 value (1 day) the 2nd dimension can have at most 24 values, ranging from 0-23 (hours of each day), and will have at least 1 value (1 hour per day) I know I can do this with a foreach on the whole ksorted array and sort each 2nd dimension array: ksort($sched); foreach ($sched as &$array) sort($array); unset($array); but I was hoping I could achieve this with native php array function(s) instead. My search led me to try array_multisort(array_values($array), array_keys($array), $array) but I just can't make it work.

    Read the article

  • Remove values from array on foreach PHP

    - by user104531
    I have an array like this: Array ( [0] => Array ( [id] => 68 [type] => onetype [type_id] => 131 [name] => name1 ) [1] => Array ( [id] => 32 [type] => anothertype [type_id] => 101 [name] => name2 ) ) I need to remove some arrays from it if the users has permissions or not to see that kind of type. I am thinking on doing it with a for each, and do the needed ifs inside it to remove or let it as it. My question is: What's the most efficent way to do this? The array will have no more than 100 records. But several users will request it and do the filtering over and over.

    Read the article

  • A Simple PHP Array Manipulation

    - by Ygam
    Hi guys! how would you turn this array: array( 0 => Title1, 1 => Title2, 3 => Address1, 4 => Address2, ) to this array: array ( 0 => array( 'title' => 'Title1' 'address' =>'Address1' ), 1 => array( 'title' => 'Title2', 'address' => 'Address2' ) ); when you were initially given $_POST['title'] = array('Title1', 'Title2); $_POST['address'] = array('Address1', 'Address2'); which when merged would give you the first array I have given I was able to solve this via a high level Arr:Rotate function in Kohana framework, along with Arr::merge function but I can't quite understand the implementation. Please help

    Read the article

  • Ruby - Subclassing array to make it randomize when flattened

    - by Markus O'Reilly
    I'm trying to subclass Array in ruby to make it randomize its elements when flatten! is called. Looking at the source code for Array#flatten (http://ruby-doc.org/core/classes/Array.src/M002218.html), it looks like it should recursively call flatten! on any array contained within an array. So, I tried doing something like this: class RandArray < Array def randomize! self.sort!{rand(3)-1} end def flatten! randomize! super end end However, when a normal array contains my RandArray and flatten is called on the normal array, flatten! is never called in my array. I figure ruby is just calling some other method to flatten the arrays recursively, but I can't figure out what that is. Any tips?

    Read the article

  • generic function for extracting values from an array with one particular key in PHP

    - by Sabya
    Is it possible in PHP to extract values from an array with a particular key path and return an array of those values? I'll explain with an example: $user = array ( array( id => 1, email =>'[email protected]', project => array ('project_id' => 222, 'project_name' => 'design') ), array( id => 2, email =>'[email protected]', project => array ('project_id' => 333, 'project_name' => 'design') ) ); /** I have to write a function something like: */ $projectIds = extractValuesWithKey($user, array('project', 'project_id')); print_r($projectIds); Output: Array( [0] => 222, [1] => 333 )

    Read the article

  • Fatal error: Cannot use string offset as an array

    - by learner
    Array ( [0] = Array ( [auth_id] = 1 [auth_section] = Client Data Base [auth_parent_id] = 0 [auth_admin] = 1 [sub] = Array ( [0] = Array ( [auth_id] = 2 [auth_section] = Client Contact [auth_parent_id] = 1 [auth_admin] = 1 ) ) ) [1] => Array ( [auth_id] => 6 [auth_section] => All Back Grounds [auth_parent_id] => 0 [auth_admin] => ,4 [sub] => Array ( [0] => Array ( [auth_id] => 7 [auth_section] => Edit Custom [auth_parent_id] => 6 [auth_admin] => 1 ) ) ) [2] => Array ( [auth_id] => 20 [auth_section] => Order Mail [auth_parent_id] => 0 [auth_admin] => 1 [sub] => ) } When I process the sub inner array it shows this error how can I avoid that :)

    Read the article

  • Ruby: how to know depth of multidemensional array

    - by hqt
    This is my problem I have met in my assignment. Array A has two elements: array B and array C. Array B has two elements: array D and array E At some point, array X just contains two elements: string a and string b. I don't know how to determine how deep array A is. For example: arrA = [ [ [1,2] ] ] I have tested by: A[0][0][0] == nil which returns false. Moreover, A[0][0]..[0] == nil always returns false. So, I cannot do this way to know how deep array A is.

    Read the article

  • php multidimensional array if loop

    - by user1091558
    I have a multidimensional array like this array[value][1][1] Now i would like to implement if loop like this if ($value = array[value][1][1]) { echo "It works"; } Now it works if i assign the values like [1][1],[2][1]. Is it possible to compare the whole array. I mean if the array looks like array[value][1][1],array[value][2][1],..........,array[value][n][1] It works should be echoed. I tried like this. if ($value = array[value][][]) { echo "It works"; } But its not working. Can anyone give me the correct syntax?

    Read the article

  • PHP 5.2 Function needed for GENERIC sorting of a recordset array

    - by donbriggs
    Somebody must have come up with a solution for this by now. We are using PHP 5.2. (Don't ask me why.) I wrote a PHP class to display a recordset as an HTML table/datagrid, and I wish to expand it so that we can sort the datagrid by whichever column the user selects. In the below example data, we may need to sort the recordset array by Name, Shirt, Assign, or Age fields. I will take care of the display part, I just need help with sorting the data array. As usual, I query a database to get a result, iterate throught he result, and put the records into an assciateiave array. So, we end up with an array of arrays. (See below.) I need to be able to sort by any column in the dataset. However, I will not know the column names at design time, nor will I know if the colums will be string or numeric values. I have seen a ton of solutions to this, but I have not seen a GOOD and GENERIC solution Can somebody please suggest a way that I can sort the recordset array that is GENERIC, and will work on any recordset? Again, I will not know the fields names or datatypes at design time. The array presented below is ONLY an example. UPDATE: Yes, I would love to have the database do the sorting, but that is just not going to happen. The queries that we are running are very complex. (I am not really querying a table of Star Trek characters.) They include joins, limits, and complex WHERE clauses. Writing a function to pick apart the SQL statement to add an ORDER BY is really not an option. Besides, sometimes we already have the array that is a result of the query, rather than the ability to run a new query. Array ( [0] => Array ( [name] => Kirk [shrit] => Gold [assign] => Bridge ) [1] => Array ( [name] => Spock [shrit] => Blue [assign] => Bridge ) [2] => Array ( [name] => Uhura [shrit] => Red [assign] => Bridge ) [3] => Array ( [name] => Scotty [shrit] => Red [assign] => Engineering ) [4] => Array ( [name] => McCoy [shrit] => Blue [assign] => Sick Bay ) )

    Read the article

  • PHP array help getting a value from the key

    - by sea_1987
    I have a variable that looks likes this, $rslt['expected_salary_level'] This returns a string similar to LEVEL_3, in another array that looks like this I have a set of salaries, Array ( [LEVEL_1] => Array ( [nice_name] => under &pound;10,000 [low] => 1 [high] => 10000 ) [LEVEL_2] => Array ( [nice_name] => &pound;10,000 - &pound;15,000 [low] => 10000 [high] => 15000 ) [LEVEL_3] => Array ( [nice_name] => &pound;15,000 - &pound;20,000 [low] => 15000 [high] => 20000 ) [LEVEL_4] => Array ( [nice_name] => &pound;20,000 - &pound;25,000 [low] => 20000 [high] => 25000 ) [LEVEL_5] => Array ( [nice_name] => &pound;25,000 - &pound;30,000 [low] => 25000 [high] => 30000 ) [LEVEL_6] => Array ( [nice_name] => &pound;30,000 - &pound;40,000 [low] => 30000 [high] => 40000 ) [LEVEL_7] => Array ( [nice_name] => &pound;40,000 - &pound;50,000 [low] => 40000 [high] => 50000 ) [LEVEL_8] => Array ( [nice_name] => &pound;50,000 - &pound;100,000 [low] => 50000 [high] => 100000 ) [LEVEL_9] => Array ( [nice_name] => &pound;100,000 or more [low] => 100000 [high] => 9999999 ) [LEVEL_VOLUNTARY] => Array ( [nice_name] => Voluntary [low] => [high] => ) [LEVEL_UNSPECIFIED] => Array ( [nice_name] => Not specified [low] => [high] => ) ) How do I get at the associated nice name?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >