arrays

How To... Sort 4 x 1D arrays?

I have four arrays all containing related data, Data Example:= (Array 1 | Array 2 | Array 3 | Array 4) R.E.M.|In Time: The Best Of R.E.M. 1988-2003|album:6G5BGhEiLvck3kvKpSYw2y|Rock Nick Drake|Family Tree|album:2euLAROPTmXDIDuU3qVMkf|Folk Sonic Youth|Dirty|album:0QPkL6ap8riBoQ5xN8YDR3|Noise Rock I would like to sort all arrays; filt...

Sort a CSV file by last name with PHP

How would I sort the following CSV file using PHP? I would like to sort by last name. Do I use regex somehow to get the first letter in the last name? Any help is appreciated Here is an excerpt of my CSV file - with a ";" delimiter between names and addresses John C. Buckley, M.D.;123 Main Street, Bethesda MD 20816 Steven P. Wood;34...

C# : obtain generic enumerator from an array

In C#, how does one obtain a generic enumerator from a given array? In the code below, MyArray is an array of MyType objects. I'd like to obtain MyIEnumerator in the fashion shown, but it seems that I obtain an empty enumerator (although I've confirmed that MyArray.Length > 0). MyType [ ] MyArray = ... ; IEnumerator<MyType> MyIEnu...

How can I implement matlabs ``ismember()`` command in Python?

Hello everyone, here is my problem: I would like to create a boolean matrix B that contains True everywhere that matrix A has a value contained in vector v. One inconvenient solution would be: import numpy as np >>> A = np.array([[0,1,2], [1,2,3], [2,3,4]]) array([[0, 1, 2], [1, 2, 3], [2, 3, 4]]) >>> v = [1,2] >>> B = (A...

Powershell - Searching and Comparing Arrays with Quest CMDlets

Trying to determine if there are any user folders on the network that don’t have an associated user account. All results return "Missing" when the majority should return "Found". Any ideas? $Dir = "\\ServerName\Share\" $FolderList = Get-ChildItem($Dir) | where {$_.psIsContainer -eq $true} $UserList = get-qaduser -sizelimit 0 | select Lo...

What is the right way of usig " and ' inside sub-arrays in PHP and HTML?

Which of the following ways is the right one in using the characters " and ' inside PHP's sub-arrays? #1 Way in debugging PHP code $_POST["login['username']"]; #2 My original way in PHP $_POST['login[username]']; My code is now broken after changing all my variables to arrays. The following is the HTML to which the variables re...

Export GridView to TXT, then upload file to server

Basically what I want to do is export an array (or GridView) to a file called "getpathin.dat". That is easy, but the method I am using downloads the file to my computer, which is what I don't want. I want to write an array to either a PRE-EXISTING file that is on the server OR create a new file on the server in a folder, and this new fi...

Fastest way to move a part of an array to the right

I need to "insert" an element at the given index in a small array. That is, to move all elements with greater indices 1 place to the right. What is the fastest way to do that in .NET? NOTE: I added my own answer, but I am still looking for an explanation and faster alternatives. EDIT: I do need an array, not a List<T> and not a linked...

Fast stable sort for small arrays (under 32 or 64 elements)

The common wisdom says that for small enough arrays insertion sort is the best. E.g., Timsort uses (binary) insertion sort for arrays up to 64 elements; from Wikipedia: Some divide-and-conquer algorithms such as quicksort and mergesort sort by recursively dividing the list into smaller sublists which are then sorted. A useful optimi...

Subsetting Flex Array

I want to subset an array.I have the following array public var sellAmount:ArrayCollection=new ArrayCollection([ {month:"Jan", sell:2000}, {month:"Feb", sell:5000}, {month:"Mar", sell:4000}, {month:"Apr", sell:6000}, {month:"May", sell:3000}, {month:"Jun", sell:9000}, {month:"Jul", sell:1100},...

MySQL Result Array in PHP

Let's say I have this query in PHP. $a = mysql_query("SELECT * FROM `users` WHERE `id` = '1' "); Which is nice and all, but I have a problem. How do I view the contents of $a, which I presume is an array like so: Index | Value ID | 1 Username | Foo Password | Bar ... ...

Sort array returned by activerecord by date (or any other column)

How can I sort an array returned by an activerecord query by a 'created_at' date column? Keep in mind, this is once the query has been executed. Don't tell me to do it in the query because I need this to happen in the view. Thanks ...

Download a file over HTTP into a byte array in C#?

Hi, I'm trying to read a file that I have a web address for into a byte array. I've been using File.ReadAllBytes to read files locally and I've been unable to figure out the cleanest way to do this for a file on the web. I imagine this is just a quick snippet of code, but everything I can find through search is only for local files....

Why is copying references to strings much slower than copying ints (but vice versa for Array.Copy())?

Let's say I want to move a part of an array right by 1. I can either use Array.Copy or just make a loop copying elements one by one: private static void BuiltInCopy<T>(T[] arg, int start) { int length = arg.Length - start - 1; Array.Copy(arg, start, arg, start + 1, length); } private static void ElementByElement<T>(T[] arg, int...

AS3 driving me nuts......

Ok here is what I am currently trying to do. I have a class called vdata.as which takes 2 paramaters both are strings sent from the main stage. Parameter one is the location for an XML file that I need to open and read. The second parameter is the name of the video I am currently looking for. Now I can get the data from the XML file and...

To put an array to a WHERE -clause in PHP without hitting X times Postgres

How can you put an array to the WHERE -clause below without creating 50 pg_execute -commands in PHP / PostgreSQL? // to get the question_ids of the newest questions $result_q_id = pg_prepare($dbconn, "query6", "SELECT question_id FROM questions ORDER BY was_sent_at_time DESC LIMIT 50;" ); ...

To understand an array in PHP when given the other variable in the array

Please, see Cha's answer where we are pretty close the final solution. We are debugging the code with these data database in PostgreSQL test sql-queries -- Problem related to the Unsolved problem in the code How can you refer to the php -element in the following array? I have the following data Array ( [1] => Array ( ...

array walk and replace in php or Javascript(phpjs)

<?php $frndof=array("name"=>'frnd_of_xyx',"id"=>001,"url"=>'tutorboy.com/frnd_of_xyx', "address"=>array("city"=>'NewZend',"zip"=>'100450')); $frndof1=array("name"=>'frnd_of_xyx1',"id"=>0011,"url"=>'tutorboy.com/frnd_of_xyx1', "frnds"=>$frndof,"address"=>array("city"=>'NewZend1',"zip"=>'100422')); $a = array( array("name"=>'xyx',"id"=>001...

php $_POST array empty upon form submission...

Hi folks, I'm baffled on this after much googling. This issue is simple, I have a custom CMS i've built that works perfectly on my dev box (Ubuntu/PHP5+/MySQL5+). I just moved it up to the production box for my client and now all form submissions are showing up as empty $_POST arrays. I found a trick to verify the data is actually being...

Combine 2 php arrays?

How can I combine these 2 array? $array1 = array("gif" => "gif", "jpg" => "jpeg", "jpeg" => "jpeg", "png" =>"png"); $array2 = array("gif" => "0", "jpg" => "90", "jpeg" => "90", "png" => "8"); I tried $array1 = array("gif" => "gif" => "0", "jpg" => "jpeg" => "90", "jpeg" => "jpeg" => "90", "png" =>"png" => "8"); But of course it di...