arrays

PHP - Combine sub-arrays and sort by value?

This is what i've got now: Array ( [0] => Array ( [0] => Array ( [id] => 53 [date] => 18 Sep 2010 10:29 [user] => 52 [post] => ytiuy ) [1] => Array ( [id...

Iterate through array and get key and value

I need to iterate through a dynamic array. The array will look something like the following: Array ( [2010091907] => Array ( [home] => Array ( [score] => Array ( [1] => 7 [2] => 17 [3] => 10 ...

PHP: Reorder arrays after unset()

There are 2 functions involved. Search array items for a given string unset() array item if string not found $array = array("first", "second", "third", "fourth"); foreach($array as $i=> $string) { if(stristr($string, "e")) { unset($array[$i]); } } "second" is the array item with the character 'e'. If its uns...

PHP/JSON - stdClass Object

I'm pretty new to arrays still. I need some help - I have some JSON, and I've run it through some PHP that basically parses the JSON and decodes it as follows: stdClass Object ( [2010091907] => stdClass Object ( [home] => stdClass Object ( [score] => stdClass Object ( ...

Why do I get "Global symbol '$href_array' requires specific package name" in Perl?

I can't seem to get these arrays to work. I'm getting errors along the following lines: Global symbol '$href_array' requires specific package name What does this mean? Here's part of my code: sub scrape { my ( $self, $DBhost, $DBuser, $DBpass, $DBname ) = @_; my ($dbh, $query, $result, $array); my $DNS = "dbi:mysql:$DBname:$DBhost:33...

PHP Array handling for first children

I'm so tired of arrays today - thrown me all over the place. So, here's the output of an array: Array ( [2010091907] => Array ( [home] => Array ( [score] => Array ( [1] => 7 [2] => 17 [3] => 10 ...

Understanding array indexing in R

The R documentation on arrays states The values in the data vector give the values in the array in the same order as they would occur in FORTRAN, that is "column major order," with the first subscript moving fastest and the last subscript slowest. It then later gives a clarifying example of this by loading data into a two dimension...

Question on equating arrays in C

Suppose I have two int arrays x and y, and both of them have length 3. x={0,1,2}. Is there any one step way to assign the values of x to y. When I do y=x, and try to print the values of y, the code does not compile. I dont want to go through the pain of writing a for loop, and write y[i]=x[i] ...

Remove duplicate string from Array

I have the following dynamically generated arrays: ,<div id="layer0" style="left: 470px; top: 286px;">Some Text</div> ,<div id="layer0" style="font-size: 68px; left: 70px; top: 286px; ">SomeText</div> ,<div id="layer1" style="font-size: 18px; left: 60px; top: 286px; ">SomeText</div> ,<div id="layer2" style="font-size: 18px; left: 50px; ...

Save array as xml

array( name => text, surname => text, country => text, date => text ) 1) How can I save this array to file as xml file? 2) How to read this file then as array? ...

Filtering out highest integer from an array of links

But of a confusing title so let me explain. I have an array of links like this: http://somesite.com/videoplayback?ip=81.0.0.0&amp;sparams=id,expire,ip,ipbits,itag,algorithm,burst,factor&amp;fexp=905602&amp;algorithm=throttle-factor&amp;itag=34&amp;ipbits=8&amp;burst=40&amp;sver=3&amp;expire=1285056000&amp;key=yt1&amp;signature=690F9475D...

What is the "acceptable" upper limit for JavaScript array size?

I left this question as generic as possible, but I do have a specific problem that I need to solve in my application and the answer to this would help. The application I am working on uses PHP/MySQL as its backend, and is set up so that no text/words/phrases visible to the user are hardcoded in the HTML/JS that is output to the browser,...

how to use zk hbox array ?

Hi, I am not sure how to use a zk Hbox Array. I am trying to create an array of ZK Hbox components and use it within a for block. void createRow(Component container, final Node fieldNode, FieldCreator [] fieldDescription) { final Vbox fieldsRows = new Vbox(); final Hbox fieldsRow = new Hbox(); final Hbox[] fieldBox; in...

Javascript array, Parse each element multiply each element by 'x'

How do I parse through an array and for each element multiply its value field by 'x' I want to pass through a a native array that contains 60 elements as follows: [ [value, key], [value, key], [value, key] ] In the above example the key field will be a number starting at 60 and counting down to 0. The value field can be any nu...

PHP sorting arrays numerically by key value

I'm trying to sort several arrays in numerical order based on the value in their first key: $array1[0] = '1'; $array1[1] = 'content'; $array1[2] = 'more content'; $array3[0] = '3'; $array3[1] = 'content'; $array3[2] = 'more content'; $array4[0] = '4'; $array4[1] = 'content'; $array4[2] = 'more content'; $array2[0] = '2'; $array2[1] =...

Object acting like an array? (PHP)

I have seen something like this in an ORM: $b = new Book(); $b->limit(5)->get(); echo 'ID: ' . $b->id . '<br />'; echo 'Name: ' . $b->title . '<br />'; echo 'Description: ' . $b->description . '<br />'; echo 'Year: ' . $b->year . '<br />'; foreach ($b as $book) { echo 'ID: ' . $book->id . '<br ...

Return the result of sum of character arrays

Recently in an interview i was asked a question to write a function which takes two character arrays(integers) as input and returns the output character array. Function Signature: char* find_sum(char* a, char* b) How would one approach this? Example scenario: find_sum("12345","32142") = "44487" Note: The number of digits can be ...

C++: Printing/assigning simple array prints gibberish

My code basically is to list ASCII codepoints of a string that is input, my following code is simple, here: #include <iostream> #include <string.h> using namespace std; int main() { char str[20]; int result[20]; cin >> str; for(int i = 0; i != strlen(str); i++) { result[i] = (int)i; } for(int i = 0; ...

How would you keep a Math.random() in javascript from picking the same numbers multiple times?

I have an array var words = []//lots of different words in it. I have a Math.floor(Math.random()*words.length) that chooses a random word from the array. This is run in a loop that runs for a random number of times (between 2 and 200 times). I would like to make sure that the random numbers do not get chosen more than once during the tim...

Sorted List Array Question

Is it possible that two sorted list of size n/2 each can be merged using n/2 size of working ?array??? ...