arrays

mysqli statement: fetch() an array of results

I use mysqli extension and bind the result to an object: class Item { public $id, $name; } $Item = new Item; $stmt->bind_result($Item->id, $Item->name); Every call to $stmt->fetch() will overwrite $Item's properties which became references. If I simply clone the object — these references remain and both instances change simult...

How to properly delete elements in java arrays

I have a simple program that lets you add, edit, list, search and delete records by storing it on arrays. My problem now, is how to properly delete items on it. Here is my current code. System.out.print("Input number to delete: "); delnum=scanz.nextLine(); intdelnum=Integer.parseInt(delnum); n...

Reading JSON arrays with jQuery/JS

Alright, this pretty much goes along with my previous question. I'm still trying to figure out how to display data from an array which is created by a PHP file- using JS/jQuery. I'm working on a points system for ZetaBoards, and I've currently got it set up here. (Points will be displayed below the users post count once I get this workin...

How do I remove duplicate strings from an array in C?

Hello, I have an array of strings in C and an integer indicating how many strings are in the array. char *strarray[MAX]; int strcount; In this array, the highest index (where 10 is higher than 0) is the most recent item added and the lowest index is the most distant item added. The order of items within the array matters. I need a...

PHP Unset + Undefined Offset

I'm having a little trouble with losing my array order after using unset(). Here's the code first: $id = $_GET['id']; for($i = 0; $i < count($my_array); $i++) { if($my_array[$i] == $id) { unset($my_array[$i]); } } Assume that $my_array has 4 items and $my_array[1] is equal to $id. After I unset that I try to run a ...

php read from file float

Hello I have a text file with three lines. every line has a float number. How can I take each value and put in a float variable even if array? For example text file is like the following +3.01\n -0.0012\n -0.1\n I want an array [if it possible] which save the values as float not as string. Thanks ...

How do you sort parrallel arrays in Perl?

Hi, I have a few arrays of the same length. I want to sort the first array, and make all the others array "sort" accordingly. For example, if the first array is (7,2,9) the second is ("seven","two","nine") and the third is ("VII","II","IX") after the sort (ascendingly according to the first array values) we will have (2,7,9) ("two","sev...

Convert { Key : Value } Object Into Standard Variables with jQuery

I give you what I want in PHP : foreach($myarray as $key=>$value) { ${$key} = $value; } Now, can we do it with JS/jQuery ? This is the jQuery input, I want the classTD value as key, in other words the equivalent of the famous PHP statement ${$key} in the example above: data = {}; $('#resul_rech_doc_fact tr.document-2 td').each(func...

Why does this PHP code just echo "Array" ?

Here is my code: if(isset($_POST['check']) AND $_POST['check'] == 'First') { $errormessage = array(); if(empty($_POST['full_name']) || strlen($_POST['full_name']) < 4) { $errormessage[] = "FEL - Vänligen ange fullständiga namn. Please enter atleast 3 or more characters for your name"; } if(!isEmail($_POST['usr_email'])) { $erro...

Arrays as function parameters

I'm trying to write a little CLI Hangman game, just to create something in C using my very limited set of language features, making the information so far stick. I haven't got to strings in the book yet, so I've created a so-called dictionary, which is a multi-dimensional array of characters, each row representing a word, and each colum...

Minimum Window for the given numbers in an array

Saw this question recently: Given 2 arrays, the 2nd array containing some of the elements of the 1st array, return the minimum window in the 1st array which contains all the elements of the 2nd array. Eg : Given A={1,3,5,2,3,1} and B={1,3,2} Output : 3 , 5 (where 3 and 5 are indices in the array A) Even though the range 1 to 4 als...

Printing array elements

The expected output of the following C program is to print the array elements. But when actually run, it doesn't do so. #include<stdio.h> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = {23,34,12,17,204,99,16}; int main() { int d; for(d=-1;d <= (TOTAL_ELEMENTS-2);d++) printf("%d\n",array[d+1])...

C++ Constructor error. Cannot initialize array of strings

Why cannot initialize my array of strings in my constructor? I get the following error: internal compiler error: Segmentation fault| at these two lines in the constructor: suits = {"Clubs", "Diamonds", "Hearts", "Spades"}; denominations = {"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"}; class Card { publ...

Mapping object signatures for required attributes

Hello, i am trying to think of the best way to create a way to store the signatures of objects, in particular products. There will be several types of products that will each have their own set of attributes and therefore different required attributes. There will be different types of actions performed on the products, i.e validation e...

Finding an element in an array in Java

Someone has to have asked this before, but I can't find it :-(. Does Java have a built-function to allow me to linearly search for an element in an array or do I have to just use a for loop? ...

Return sql query as array

Hello, I'm using jqueryui and its Autocomplete plugin. It use a json to extract items. I want to modify it so that items will be extracted from my db. Here is how items should be : $items = array( "Great <em>Bittern</em>"=>"Botaurus stellaris", "Great2 <em>Bittern</em>"=>"Botaurus stellaris 2" ); How to make an sql query that extra...

How to store bits to a huge char array for file input/output

HI, all. Here are the things I want to do : I want to store lots of informations to a block by bits, and save it into a file. In order to keep my file not so big, I only want to use a small number of bits to save specified information instead of a int. For example, I want to store Day, Hour, Minute to a file. I only want 5 bit(day)...

How to make a multidimension numpy array with a varying row size?

I would like to create a two dimensional numpy array of arrays that has a different number of elements on each row. Trying cells = numpy.array([[0,1,2,3], [2,3,4]]) gives an error ValueError: setting an array element with a sequence. ...

Unexpected long process time when reading a byte array

I have a program that need to handle byte array source. Originally the program work fine when the byte array size is 3000 byte. Now data size increase and the array size need to be changed from 3000 to 30000 (10 times). I make a sample benchmark program to test looping time. I suppose required CPU time should be increase linearly acc...

Fill arrays with ranges of numbers

Hi, Is there any syntax/package allowing quick filling of java arrays with ranges of numbers, like in perl? e.g. int[] arr = new int[1000]; arr=(1..500,301..400,1001..1400); // returns [1,2,3,4,...,500,301,302,...,400,1001,1002,...1400] Also, it here a package that allows getting the n-th number in such list of numbers as the above,...