arrays

What is meant by 2D array support?

I read that Python does not actually support 2D arrays but rather an array of an array. I understand the array of an array thing but what does it mean by supporting 2D arrays? In C a 2D array is simply converted to a 1D array by doing some fancy math (Seen here). Are there languages that implement actual 2D arrays? Thanks for the hel...

jQuery element index in array

I have several images loaded into the DOM via jQuery. Each image has 'display: none' aside from one which is 'display: block'. It's this image which I need to find the index of once selecting the img array from the DOM. The trouble is, img[style="display: block"] doesn't seem to be working as 'display' isn't the only style set on the el...

How do I divide NSString into smaller words?

Greetings, I am new to objective c, and I have the following issue: I have a NSString: "There are seven words in this phrase" I want to divide this into 3 smaller strings (and each smaller string can be no longer than 12 characters in length) but must contain whole words separated by a space, so that I end up with: String1 = "Ther...

how do you compare a param to every item in an array in rails?

i have a codes model and i a basically have a form wich should authenticate simply to every code recorded so my controller is: def cancel_sale @codes = Code.find(:all) @codes.each do |c| @code = c.name end if params[:auth] && params[:auth] == @code something else @mensaje_de_salida = "wrong auth code" en...

array conversion in php

how would you convert this array: Array ( [0] => Array ( [Contact] => Array ( [number] => 0425 234 634 ) ) [1] => Array ( [Contact] => Array ( [number] => 2939 492 235 ) ...

define integer array fortran

Hello friends, I am a newbie in Fortran. Can any1 tell me how to define an integer array in prior. E.g. I want to define an array with no.of days in 12 months. like... integer,allocatable(12,1) :: days days=[31,28,31,30,31,30,31,31,30,31,30,31] Is this syntax correct? If not, please let me know the correct one. Thanks Praveen ...

String Array Thing!

Right - to start with, I'm entering unfamiliar areas with this - so please be kind! I have a script that looks a little something like this: Private Function checkString(ByVal strIn As String) As String Dim astrWords As String() = New String() {"bak", "log", "dfd"} Dim strOut As String = "" Dim strWord As String For Eac...

Best practice of big javascript objects

Hi all, sry for this imprecise topic name. I am querying a dataset a lot of times so using ajax request would end up in tons of http requests. For this reason I decided to use the json encode method to store this particular data set in my javascript code. My php code looks like this: (no json.parse) echo 'var myDataset = ' . json...

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 [cat_title] => Drawings [sec_title] => Portfolio ) [1] => Array ( [title] => title 2 ...

How to pass an array?

Hello! How could I pass an array with PHP by GET method? Thanks ...

Initializing array of objects with data from text file

I’m getting system error when I try to compile the code below on Visual C++ 2008 Express. What I’m trying to do is to initialize array of objects with data read from file. I think there is something wrong inside the while loop, because when I initialize these objects manually without the while loop it seems to work. Here is the code an...

make bash array from incrementally adding another array

So if I have a bash array: ar=( "one" "two" "three" "four") What is the best way to make a new array such that it looks like this: ar-new=( "one" "one two" "one two three" "one two three four" ) I cooked up something that use a for loop inside a for loop and using seq. Is there a better/more elegant way to accomplish this? ...

How can I use index or rindex with a block in Ruby?

Is there any Array or Enumerable built-in that allows me to search for an element using a block, and return its index? Something along the lines of : ar = [15,2,33,4,50,69] indexes = ar.find_indexes {|item| item > 4 == 0} # indexes will now contain 0,2,4,5 It would be very easy to add my own, but I'd like to know if this already exis...

-> Arrow operator with Arrays?

Can you use the arrow operator with an array of type struct. For example: struct { char *foo; } fooArray[10]; fooArray[0]->foo = ... ...

Subsequence with maximum sum in array of ints

Given an array of integers, how can you find two indices, i and j, such that the sum of the elements in the indices is maximized, in linear time? ...

undefined index

when accessing a set of information in a database i am then trying to print the names, however i get an undefined index error: $val= mysql_query("select * from country"); while($row = mysql_fetch_array($val)){ echo $row['country']; } i think it maybe to do with not check if isset correctly, is there an example related ot this tha...

Text box value into array instead of options

I'm working on a wordpress plugin, and have come across a barrier of sorts. I need to take in a value from a textbox from the options page, but I don't want that information stored within the options.php file. Instead, I need to get that value, and then store it within an array, and later that array will be filed into the options.php fil...

Inserting leading zeros into an integer

I have a function in C which generates a number of hours from a rtc peripheral, which I then want to fill an array within a struct object. The array is set up to take 5 digits, but I need to prepend leading zeros to the number when it is less than 5 digits. Could anyone advise on an easy way of achieving this? ...

PHP Recursively unset array keys if match

I have the following array that I need to recursively loop through and remove any child arrays that have the key 'fields'. I have tried array filter but I am having trouble getting any of it to work. $myarray = array( 'Item' => array( 'fields' => array('id', 'name'), 'Part' => array( 'fields' => array('pa...

StringCollection or ArrayList within Class

Hi there, I have a class called CookieMonster, its objective is to simply create a cookie based on 3 parameters passed to it. The cookie name, the cookie name-value pairs and the cookie expiry date. I have experimented with List(of T) and Array and StringCollection, but I'm unsure which is the best for passing the name-value pairs and ...