arrays

Merging PHP arrays

I am working on a project at the moment, that allows the user to create any number of news headlines, articles and images, the only rule with this system is that a headline must have an article and an image. My question is on my form when I submit I get 2 arrays one is the $_POST and the other is $_FILES. $_POST Array ( [campaign_...

Transform an array into a string inline

What is the tersest way to transform an integer array into a string enumerating the elements inline? I'm thinking something like an anonymous function that performs the conversion. var array = new int[] { 1, 2 } var s = string.Format("{0}", new [] { /*inline transform array into the string "...

Why isn't my index variable increasing when I add numbers to it?

I've got the following float array public static float camObjCoord[] = new float[8000]; declared as a global variable. I'm then adding content to it by calling the following method: public void addcube(float highx, float lowx, float highz, float lowz){ //Constructing new cube... Global.cubes = Global.cubes + 1; float highy =...

Removing array elements

Hi, how do I remove an element from a Perl array ref? I've got its index and I don't want to set the element to undef, but to remove it completely. For example, how do I change $a = [1, 2, 3]; into $a = [1, 3];. ...

Problem with array assignment

Hey guys, I've got the following problem with an array assignment... I've got a global float array in Global.java declared as... public static float camObjCoord[] = new float[8000]; I'm then filling its contents with. public void addcube(float highx, float lowx, float highz, float lowz){ //Constructing new cube... Sy...

Joining more than two mysql tables then manipulating rows into grouped multidimensional arrays

I'm trying to join multiple myqsl tables and then process resulting arrays using PHP but I'm having problems manipulating my data to get the groupings I'd like. table.users +--------------- uidname table.profile_values +----------------------- fiduidcategory_value table.profile_fields +--------------------- fid catego...

Copying a file line by line into a char array with strncpy

So i am trying to read a text file line by line and save each line into a char array. From my printout in the loop I can tell it is counting the lines and the number of characters per line properly but I am having problems with strncpy. When I try to print the data array it only displays 2 strange characters. I have never worked with ...

Global float array values are not transfering classes

Hi Guys, This is a follow up question from http://stackoverflow.com/questions/3238690/problem-with-array-assignment I now have addcube done like so.. and all works as expected, when I print the array. but when I print the same index's AFTER assignment in another class It tells me their equal to 0. So the values are not 'saving'. Why is...

How to manage python threads results?

I am using this code: def startThreads(arrayofkeywords): global i i = 0 while len(arrayofkeywords): try: if i<maxThreads: keyword = arrayofkeywords.pop(0) i = i+1 thread = doStuffWith(keyword) thread.start() except KeyboardInterrupt: ...

Wordpress query_posts() with an array?

I'm trying to query posts based on a number of ID's that are contained in an array. My array (called $my_array) looks like this: Array ( [0] => 108 [1] => 129 [2] => 145 ) And my Query looks like this: <?php query_posts(array('post__in' => $my_array)); ?> However this just returns one post, the post has the ID of the f...

Is this an efficient use of the Array.filter() method for searching and retrieving an Object instance from an Array?

I am curious if this is an okay implementation of the Array.filter() method. //Array of generic Object instances representing galleries. //The images property is empty for the example var galleries:Array = new Array(); galleries[0] = {name: 'Portraits', images: new Array()}; galleries[1] = {name: 'Landscapes', images: new Array()}; ga...

Why Pascal const arrays aren't actually constants?

Program ConstTest; Const constVar = 1; Begin constVar := 3; WriteLn(constVar); End. It's pretty obvious that the above code will not compile, because it's not right to change the value of a constant. However, following code will compile, and will return "1; 5; 3;", even though the array is a const: Program ConstTest; ...

Javascript is passing an Array of Objects instead of an Array of Arrays...

I'm passing a Javascript Array() to Flash via FlashVars but Flash complains. Can you guys point me what am I doing wrong here? javascript code // array with the user defined cities var usercities = new Array( {'nome':"London", 'lat':51.5002, 'long':-0.1262 }, {'nome':"NYC", 'lat':51.5002, 'long':-0.1262 } ); flashvars.newcit...

How to add up rows (and columns) of a 2D array.

How would I write a function to add up the content of each row in a 2D array? To add the contents of each column? my code (so far): #include <iostream> using namespace std; const int QUARTER = 4; void getdata(float [][QUARTER], int); void displaydata (float [][QUARTER], int); void quartertotal(float [][QUARTER], int); int main() { ...

Parse string to get an array of the URLs

Hi, Imagine I have a string - something like this: This is some really cool text about http://google.com/ and it also contains some urls like http://apple.com/ and its very nice! This is too long and I need to do some magic stuff to fix this very big problem. Oh no. As you can see there are two URLs in the string and somehow, assumin...

jQuery: Index of element in array where predicate

I have an array of objects. Each object has, among others, an ID attribute. I want to find the index in the array of the object with a specific ID. Is there any elegant and simple way to do this in jQuery? ...

variable read from text file and passed to smarty shows up like "Home<i>\r</i><i>\n</i>"?

I have a code that look like this. $language = "eng"; $append = "_sidebar.txt"; $read_text_file = "languages\\$language$append"; $sidebar = file($read_text_file); $smarty->assign("sidebar_link",$sidebar); Why does all variables in smarty all look like this: Smarty_Variable Object (3) ->va...

Why isn't a function's arguments object an array in Javascript?

Since it seems like the first thing people do is convert arguments into a real array, I'm interested in why the Javascript language authors and implementers decided, and continue to think, that arguments should not be a real Array. I don't mean this as flamebait, I'm sincerely interested in the thinking behind it. Since the function is n...

Exploding a string and looping through an array in MySQL outside another language

I'm creating a MySQL UDF (User Defined Function) to capitalise the first letter of every word. This is what I have so far: drop function if exists upperfirst; create function upperfirst (s varchar(255)) returns varchar(255) deterministic return concat(ucase(mid(lower(s),1,1)),mid(lower(s),2)); This is working pretty well so ...

English list...

I have a scenario where I need to supply users a message. The message can be in the following forms: "John likes to eat < b>squirrel< /b>." "John likes to eat < b>squirrel< /b> and < b>gator< /b>." "John likes to eat < b>squirrel< /b>, < b>gator< /b> and < b>birdpoop< /b>." "John likes to eat < b>squirrel< /b>, < b>gator< /b>, < b>bir...