arrays

multiple mysql queries into one php two-dimensional array

I'm refactoring my code and just hit a snag. The first query in the code below gets the tab_id of the latest submitted tabs. The second Query gets the detail of each tab. In my old way of doing it, i embedded php and html and it was truly an utter mess. Right now I'd like to merge the 2 queries into 1 and/or load it into an array. feel...

When out of index of fixed array how to pragmatically restart at beginning.

Requirements: Return total count of files (records) for date. Assign a modifier (single character A-Z 0-9) to represent the count. Info: This modifier along with the date / time will be used to trace the file through out the system. Current Solution: [Test] public void FileIDModifierShouldReturn9() { var filecountfor...

.NET equivalent to java.util.Arrays.hashCode() function for arrays of intrinsic types?

Is there a.NET utility class equivalent to java.util.Arrays.hashCode() for arrays of intrinsic types such as int[], short[], float[], etc.? Obviously I could write my own utility class but was trying to find one already available in the .NET framework. ...

Why does my C# array lose type sign information when cast to object?

Investigating a bug, I discovered it was due to this weirdness in c#: sbyte[] foo = new sbyte[10]; object bar = foo; Console.WriteLine("{0} {1} {2} {3}", foo is sbyte[], foo is byte[], bar is sbyte[], bar is byte[]); The output is "True False True True", while I would have expected "bar is byte[]" to return False. Apparently ...

Sort String Array As Int

Is there some way to use IComparer with ArrayList.Sort() to sort a group of strings as ints? ...

Mysterious oneliner template code, any one ?

I was reading this page : C++ Tip: How To Get Array Length. The writer presented a piece of code to know the size of static arrays. template<typename T, int size> int GetArrLength(T(&)[size]){return size;} // what does '(&)' mean ? . . . int arr[17]; int arrSize = GetArrLength(arr); // arrSize = 17 Could anyone please shed the light o...

Multidimensional array only returning one item in PHP

I have a multidimensional array, that is a few levels deep. I am trying to loop through some of the lower levels of array items, but when I do, it seems to only return one of the array items. foreach ($items as $item) { foreach ($item as $id) { echo $id; } } For some reason, echoing $id only returns the first item in the $ite...

Pass Arrays to SQL Functions from .NET C#

Hi, There is any chance to pass arrays to SQL Functions from .NET C#. Thanks in advance. Sincerely. And Could you show me how ? ...

JQuery hover() possibilities!?

I'm using hover() as suggested in the documentation: $("#div").hover( function(){$(this).addClass('cie_hover');}, function(){$(this).removeClass('cie_hover') ;} ); Is there a way I can use more functions on other objects? And if so what would be the syntax to introduce functions in array? What I would like...

php array and foreach?

Below is my code I am trying to get to work but I really have very little knowledge of array and foreach. So it doesn;t work correctly I need to show a dropdown select form to the browser with the contents of the array I also need to have the item selected if it is == to $mycountry Lastly I would like to show the USA and UK at the top ...

Recursion/iteration troubles, transforming an array of words into phrases

I'm trying to build a list of "phrases" using an array of word lists. I have an array that looks something like this: [ [ 'big', 'small', 'wild' ], [ 'brown', 'black', 'spotted' ], [ 'cat', 'dog' ] ] The first array is the first word in the resulting "phrase", the second array is the second word, and so on. The number of word list...

php in array error

<?PHP $bannedIPs = array('127.0.0.1','72.189.218.85'); function ipban() { if (in_array($_SERVER['REMOTE_ADDR'], $bannedIPs)) { echo 'test'; } } ipban(); ?> The output of this script is: Warning: in_array() [function.in-array]: Wrong datatype for second argument in C:\webserver\htdocs\test\array.php on line 93 Can so...

php imploding array help

I am trying to the implode the userIDs in the $users_in_range array the problem is it is iploding miles instead of userid <?PHP $users_in_range = users_in_range($lat, $long, 500, true); // implode users into mysql friendly list $comma_separated = implode(",", $users_in_range); echo $comma_separated; // this is just for output while...

Javascript: Determine whether an array contains a value

i need to determine if a value exists in an array using javascript. I am using the following function: Array.prototype.contains = function(obj) { var i = this.length; while (i--) { if (this[i] == obj) { return true; } } return false; } The above function always returns false. The array val...

Extract leaf nodes of multi-dimensional array in PHP

Suppose I have an array in PHP that looks like this array ( array(0) ( array(0) ( . . . ) . . array(10) ( .. ) ) . . . array(n) ( array(0) ( ) ) ) And I need all the leaf elements of this mulit-di...

[PHP] get only 5 elements from array

Hi all, my array is setup as follow: array 'testuri/abc' => array 'label' => string 'abc' (length=3) 'weight' => float 5 'testuri/abd' => array 'label' => string 'abd' (length=3) 'weight' => float 2 'testuri/dess' => array 'label' => string 'dess' (length=4) 'weight' => float 2 ...

C++ array excercise-help needed

Hello, I'm C++ begginer. I did this excercise from Deitel's book: Use a one-dimensional array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the array only if it is not a duplicate of a number already read. After read...

Any way to access array directly after method call?

Is there any way to do this in one line? $arr = $foo->getBarArray(); return $arr[0]; This throws an error: return $foo->getBarArray()[0]; ...

2D-float array values scan

Hi, I wrote a code by using C language as follows: main() { float x[10][10]; int i,j; clrscr(); scanf("%d%d",&i,&j); for(i=0;i<3;i++) for(j=0;j<3;j++) scanf("%f",&x[i][j]); ...... } When i run this program, there is an ABNORMAL TERMINATION with the error like 'FLOATING POINT CONVERSIONS NOT LINKED'...

Java Performance - ArrayLists versus Arrays for lots of fast reads.

I have a program where I need to make 100,000 to 1,000,000 random-access reads to a List-like object in as little time as possible (as in milliseconds) for a cellular automata-like program. I think the update algorithm I'm using is already optimized (keeps track of active cells efficiently, etc). The Lists do need to change size, but tha...