arrays

javascript string split negative

Is it possible to use string split in javascript to get the last element in the array that is produced. For example, im sure in php you can do the same and use a negative limit value to get the last item i.e. -1 or the last two items -2 etc. ...

Adjusted Cosine Similarity

Hello there. Can you help me, please. I was confused to make PHP code about adjusted cosine similarity. I have build data like this : $data[UserID][ItemID] = Rating data example : $data[1][1] = 5; $data[1][2] = 3; $data[1][3] = 4; $data[2][1] = 3; $data[2][2] = 2; $data[2][4] = 3; $data[2][5] = 3; $data[3][1] = 4; $data[3][3] = 3; $d...

Copying an SMO collection into an array in Powershell

I've written a Powershell script which will compare two databases and come up with a list of objects in one of the databases to remove. I put those items (as a customized object with a name and schema) into an array. In the next step of my script I iterate through the objects in the database and see if they match an object in my array. ...

PHP: searching for the coincidence in the string

I would like to filter HTTP_REFERER where visitors come to my site from search engines. I want to ignore storing HTTP_REFERER information for the visitors came from the search engines. Could you please help with the PHP script? I have this, but not correct script: <? $exp_list = array('google', 'yahoo'); // exapmple of one HTTP_REFERE...

Turn X arrays into a single array

I want to change the format of this array to match another one. One was pulled from a database, and the other was made using space delimted user input and then explode(); So here are the arrays I want to change, this is from the database (mysql_fetch_array). It grabs the single field from all rows. Array ( [name] => daniel ) Arr...

Can I declare and initialize an array with the same instruction in Java?

Is there a way to do the following at the same time? static final int UN = 0; // uninitialized nodes int[] arr; // ... code ... arr = new int[size]; for (int i = 0; i < 5; i++) { arr[i] = UN; } Basically, I want to declare arr once I know what its size will be and initialize it to UN without having to loop. So something like thi...

What is the default initialization of an array in Java?

So I'm declaring and initializing an int array: static final int UN = 0; int[] arr = new int[size]; for (int i = 0; i < size; i++) { arr[i] = UN; } Say I do this instead... int[] arr = new int[5]; System.out.println(arr[0]); ... 0 will print to standard out. Also, if I do this: static final int UN = 0; int[] arr = new int[5];...

creating multi dimensional varchar/text arrays in plpgsql (postgres)

i have some functionality i'd like to get from the server-side code into the database. i can't figure out how to set the values of a multi-demensional varchar array in plpgsql. here is an example of what i'm trying to do: `CREATE OR REPLACE FUNCTION my_function (my_arg integer) RETURNS text[][] AS $$ DECLARE my_arr varchar[]...

How does Pythonic garbage collection with numpy array appends and deletes?

Hi all, I am trying to adapt the underlying structure of plotting code (matplotlib) that is updated on a timer to go from using Python lists for the plot data to using numpy arrays. I want to be able to lower the time step for the plot as much as possible, and since the data may get up into the thousands of points, I start to lose valua...

Combine arrays PHP

HELLO SORRY FOR FRENCH , i will try english i have tree arrays like this $keys = array("elment1","elment1","elment2","elment1"); // this one can have duplicates values , $operator = array("=","<",">","="); // operators for Mysql query $queries = array("query1","query2","query3","query4"); // mixtes values the question is : ...

Approach: Java array having instances of two different classes

I am trying to create a simple regex kind of thing for my own use where a character in a string can either be an exact match or one in among a set of characters belonging to a group (e.g., Group CAPS will have all uppercase characters - 'A', 'B', etc.). Therefore a regex such as - CAPS p p l e - should match 'Apple' or a regex such as -...

JavaScript Array to String

I'm using the jQuery plugin jQuery-Tokenizing-Autocomplete in a rails application with a has_many association. I need to save the values to the database, but to do that I need it to be a string, not an array. So the result should equal "1","2","3". Hope this clarifies. The javascript used to generate this array: $.TokenList.ParseValue...

Sorting a PHP Array into Columns

I have a mysql table that includes the fields: Name - Year - Description I'd like to display in order by year, but want to split into to columns by decade. My PHP skills are pretty weak, so I only know how to do it the long way where I make a separate query based on the year range: <?php echo "<div><h3>1950</h3>"; $list1950 = mysq...

Parsing XML into Array

So i have this XML structure: <fields> <field name="agent_description" label="Agent Description" size="area" /> <field name="agent_phone" label="Agent Phone" size="field" /> <field name="agent_email" label="Agent EMail" size="field" /> <field name="agent_listing_url" label="Agent Listing" size="field" /> <field name=...

String initializer and read only section

Suppose that I have an array(local to a function) and a pointer char a[]="aesdf" and char *b="asdf" My question is whether in the former case the string literal "aesdf" is stored in read only section and then copied on to the local array or is it similar to char a[]={'a','e','s','d','f','\0'}; ? I think that in this case the characte...

Pylons formencode - How do I POST an array of data?

I have a form that is similar to the following: Enter Name: Enter Age: [add more] That add more field copies the Name and Age inputs and can be clicked as many times as the user wants. Potentially, they could end up submitting 50 sets of Name and Age data. How can I handle this received data when it's posted to my Pylons application?...

iPhone Objective C - Saving Data

I have a NSMutableArray of some instances of a custom class (it has a NSString, CGPoint, and a UILabel). I need to save this array. I tried using writeToFile:Atomically: but that doesn't work with custom classes (I think). Is there any other simple way to save that? And how would i load it? Thanks everybody in advance:) Any ideas, sugg...

Performance of FOR vs FOREACH in PHP

First of all, I understand in 90% of applications the performance difference is completely irrelevant, but I just need to know which is the faster construct. That and... The information currently available on them on the net is confusing. A lot of people say foreach is bad, but technically it should be faster since it's suppose to simpl...

Purpose of static keyword in array parameter of function

While browsing some source code I came across a function like this: void someFunction(char someArray[static 100]) { // do something cool here } With some experimentation it appears other qualifiers may appear there too: void someFunction(char someArray[const]) { // do something cool here } It appears that qualifiers are onl...

delete function in cpp

hi, I saw an example of using the function: delete in cpp and I didn't completely understand it. the code is: class Name { const char* s; //... }; class Table { Name* p; size_t sz; public: Table(size_t s = 15){p = new Name[sz = s]; } ~Table { delete[] p; } }; what is the exact action of the command: de...