arrays

stdClass Object problems

I'm struggling to parse the below data using PHP. An API returns it, and I've tried various syntaxes. How do I return the data in a non-object way? Or, what's the syntax to call the data using the stdClass? Could I convert this to one data based array, or even two? I'm lost when it comes to object-based data sets. stdClass Object ( ...

Optimal way to free() a malloc'ed 2D array in C

Supposing I have a 2 dimensional array which was created with something like this, char **foo = (char **) malloc(height * sizeof(char *)); for(i = 0; i <= height; i++) foo[i] = (char *) malloc (width * sizeof(char *)); First of all, Is this even the right way to create an array like this?. The catch here is, 'height' and 'width' ...

Convert RGB IplImage to 3 arrays

I need some C++/pointer help. When I create an RGB IplImage and I want to access i,j I use the following C++ class taken from: http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html template<class T> class Image { private: IplImage* imgp; public: Image(IplImage* img=0) {imgp=img;} ~Image(){imgp=0;} ...

(Flex 3) How do I get data from a xml file using HTTPservice and save the return data as an array?

Hi, I have an xml file (externally saved) that is similar to the following: [root]   [main]     [title]...[/title]     [content]...[/content]   [/main]   [main]     [title]...[/title]     [content]...[/content]   [/main] [/root] *All <> is replaced with []. What I like to do is to get what's in [title] tag using HTTPservice, import it...

Find Javascript array length without deleted items

Just a simple question that I can't seem to find the answer to. myarray.length() The above will return the length including deleted items. How do I get the length without deleted items? Thanks EDIT: Thanks for the answers. I am deleting by writing 'delete myarray[0]' and this works well. Other sections of the script rely on the l...

Get specific data from a string? C#

I have a string named group. string group="|17|11|"; So my issue is that I want my output to be something like this: 17 11 so these 2 numbers should be stored in the database as two records. and another case if the string group = "|17|11|05|"; it will store 3 values in the database. The number of groups always differs in differe...

Sort php array on one column and output to list

I have created an array that is populated from a wordpress loop:- <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> $alisting []["questions"] = $questions; $alisting []["id"] = $post->ID; $alisting []["title"] = $post->post_title; <?php endwhile; ?> This outputs Array ( [0] => Array ( [quest...

Can the array be reinvented in Ruby?

This is just a hypothetical question, if you wouldn't have the Array and the Hash class, would there be any way of implementing an Array class in pure Ruby? How? ...

Returning first x items from array

Hi, I want to return first 5 items from array. How can I do this? ...

How can I iterate through nested arrays in Perl?

I have created an array as follows while (defined ($line = `<STDIN>`)) { chomp ($line); push @stack,($line); } each line has two numbers. 15 6 2 8 how do iterate over each item in each line? i.e. I want to print 15 6 2 8 I understand it's something like foreach (@{stack}) (@stack){ p...

how to loop through associative array and echo out to list?

Hi I have managed to get my first array working but no matter how many code examples I try I cannot step through each array row and echo the three columns / elements out to a . The var_dump of my array is:- array(27) { [3]=> array(3) { ["id"]=> string(3) "295" ["title"]=> string(24) "ask.sqlservercentral.com" ["questions"]=> in...

Ruby: Comparing two Arrays of Hashes

I'm definitely a newbie to ruby (and using 1.9.1), so any help is appreciated. Everything I've learned about Ruby has been from using google. I'm trying to compare two arrays of hashes and due to the sizes, it's taking way to long and flirts with running out of memory. Any help would be appreciated. I have a Class (ParseCSV) with mul...

Fortran read from char(len=15) array(dimension(1:77)), to char string (len=15)

how do I read from an array into a user defined variable... in Fortran? ...

Range of Years in JavaScript for a select box

I'm trying to create a dynamic select box in JavaScript with a range of years starting with 'some' year and ending with the current year. Is there anything like Ruby's range class in JavaScript or do I have to loop trough the years using a for loop? Here's what I've come up with though I think it's a bit much considering in Ruby I can ...

Converting tickboxes in a form to any array in $_POST

What's the best way to collect data from a form using checkboxes so it's nicely grouped into one array from the $_POST array in the receiving page. For example, in my form i'll have HTML which looks like this (x = ticked): [x] Option One [ ] Option Two [x] Option Three which i want to translated into an array from the $_POST array: ...

Why must a pointer to a char array need strcpy to assign characters to its array and double quotes assignment will not work?

The first example does not work when you go to delete the pointer. The program either hangs when I add the null terminator or without it I get: Debug Assertion Failed Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) from Visual Studio 2008 //Won't work when deleting pointer: char *at = new char [3]; at = "tw"; // <-- not sure what'...

How does C allocate data items in a multidimensional array?

I'd like to find out how C will allocate a the data items of a multidimensional array, and if their allocation is consistent across machines. I know that, at the lowest level, the data items are neighbours, but I don't know how they're arranged further up. For example, if I allocate a 3D array as int threeD[10][5][6], can I assume that...

Transfer Byte array from server to browser

I have a database column that contains the contents of a file. I'm converting this into a byte[] on the server (I don't want to save the file to the disk) and then want to send this to the client to download. The file can be any thing (pdfs, pics, word, excel, etc). I have the file name so I know the extension but I'm not sure how the ...

Can c++ create array of pointers to different classes dynamically loaded from dll?

Can c++ create array of pointers to different classes dynamically loaded from dll? ps.without headers with class definations ...

How do I know what data type to use in Python?

I'm working through some tutorials on Python and am at a position where I am trying to decide what data type/structure to use in a certain situation. I'm not clear on the differences between arrays, lists, dictionaries and tuples. How do you decide which one is appropriate - my current understanding doesn't let me distinguish between t...