arrays

JQuery Ajax post data not arriving

Hi folks, my Ajax post data is not arriving - any clues please. The data is a serilaized form that "alerts" correctly with all the data using this $(document).ready(function() { var serial = $('#frm_basket').serialize(); alert(serial); $.ajax({ url: "basket-calc.php", type: "post", data: serial, success: function(){ ("#baske...

PHP: check if object/array is a reference

Sorry to ask, its late and I can't figure a way to do it... anyone can help? $users = array( array( "name" => "John", "age" => "20" ), array( "name" => "Betty", "age" => "22" ) ); $room = array( "furniture" => array("table","bed","chair"), "objects" => array("tv","radio","bo...

How to set up the arrays for glDrawElemetnts (OpenGL ES iPhone)?

How to wire up the values for glDrawElements? I need a simple textured square example (2 face, normals, textCoords, nothin' more). I tried to do it (the arrays at glDrawArrays implementation works fine, but something went wrong when I create the indices and all), but the screen was empty. Please shed me a light, I've googled the whole ...

RecursiveArrayIterator current array

I am trying to get the whole current array and I don't think I have gone the right way about it as I get an Undefined index error sometimes. $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($comments_array), RecursiveIteratorIterator::SELF_FIRST); while ($iterator->valid()) { if ($iterator->hasChildre...

how to sort a string array by alphabet?

Hi, i've got a array of many strings. How can I sort the strings by alphabet? ...

reference variable array

Hi, i used always $text = $datasql[0]; where $datasql = array('0'=>array('some'=>'text', 'some2'=>'text2'), '1'=>$data, etc...); and found work costruction $datasql = &$datasql[0]; and work, why? That really reference?? and how remeber php in memory this solution. Thanks for reaply ...

Yet another Dynamic Array vs. std::vector, but...

...well, I got strange results! I was curious about the performance of std::vector vs. that of a dynamic array. Seeing as there are many questions on this subject already, I wouldn't have mentioned it if I didn't constantly get these 'contradictory' results: vector<int> is somehow faster than a new int[]! I always thought that if there ...

Inserting Array References into Perl Heap

I am inserting 2-dimensional array references into my heap in Perl. How should I define the 'elements' attribute when constructing my heap so that I can properly use my comparator function? my $heap = Heap::Simple->new( order => \&byNumOrStr, elements => [Array => 0] ); ...

Compare 2 elements of two arrays in C++

I have two arrays each array has some values for instance: int a[] = {1, 2, 3, 4}; int b[] = {0, 1, 5, 6}; now I need to compare the elements of the array (a) with elements in array (b).. if is there any match the program should return an error or print "error there is a duplicate value" etc.. in the above situation, it should retur...

Standard API way to check if one array is contained in another.

I have two byte[] arrays in a method like this: private static boolean containsBytes(byte[] body, byte[] checker){ //Code you do not want to ever see here. } I want to, using the standard API as much as possible, determine if the series contained in the checker array exists anywhere in the body array. Right now I'm looking at some ...

Java: How can I dynamically create an array of a specified type based on the type of an object?

Hi, I would like to take a passed List that I know is homogeneous and from it create an array of the same type as the elements within it. Something like... List<Object> lst = new ArrayList<Object>; lst.add(new Integer(3)); /// somewhere else ... assert(my_array instanceof Integer[]); ...

C++ cast to array of a smaller size

Here's an interesting question about the various quirks of the C++ language. I have a pair of functions, which are supposed to fill an array of points with the corners of a rectangle. There are two overloads for it: one takes a Point[5], the other takes a Point[4]. The 5-point version refers to a closed polygon, whereas the 4-point versi...

Pretty print array object, not array of objects?

So, I've already discovered Arrays.toString(arr); So don't point me to this question. My problem is just a tiny bit different. In this case, I don't have a native array pointer to the array in question. I have it as an Object pointer, and it could be an array of any type (primitive or otherwise). In this case, I can use the above toS...

jQuery and Native JavaScript Array - error

var tmpANArray = []; for (var i in associatedPpl) { tmpANArray.push(associatedPpl[i]); } alert('about to call toJSON on AssociatedPpl'); alert(tmpANArray); // the next line fails because $.toJSON is getting fed a function var jsonEncodedAssociatedPpl = $.toJSON(tmpANArray); What part of JavaScript/jQuery am I missing? UPDATE The J...

How to fill a 2D array diagonally based on coordinates

I'm building a heatmap-like rectangular array interface and I want the 'hot' location to be at the top left of the array, and the 'cold' location to be at the bottom right. Therefore, I need an array to be filled diagonally like this: 0 1 2 3 |----|----|----|----| 0 | 0 | 2 | 5 | 8 | |----|----|----|----| 1 | 1 | 4...

slice (unsorted) array at value in python

Given the array a = [1,1,12,3,5,8,13,21] I can slice off the first 3 elements like a[:3] giving [1,1,2]. What I want is to slice off up to the element of vlaue i (e.g. if i=8 I want [1,1,12,3,5,8] or [1,1,12,3,5] (I can work with either)). This works: return a[:a.index(i)] but only if I give it a value that's in the array. Is ther...

Sort an array of hashes by a value in the hash

Hello, this code is not behaving as I would expect: # create an array of hashes sort_me = [] sort_me.push({"value"=>1, "name"=>"a"}) sort_me.push({"value"=>3, "name"=>"c"}) sort_me.push({"value"=>2, "name"=>"b"}) # sort sort_me.sort_by { |k| k["value"]} # same order as above! puts sort_me I'm looking to sort the array of hashes by ...

Combine two constant strings (or arrays) into one constant string (or array) at compile time

In C# and Java, it's possible to create constant strings using one or more other constant strings. I'm trying to achieve the same result in C++ (actually, in C++0x, to be specific), but have no idea what syntax I would use to achieve it, if such a thing is possible in C++. Here's an example illustrating what I want to do: #include <st...

Can't get my array numbers to compare to the other set.

I have two arrays that both hold 5 sets of random numbers. First I display a list of all the numbers in the first array; then I need to add to that list, any number that's not in the first array, and display each of those. To do that, I use another array to put the unique values in to display. I already have a function that displays the...

ctypes initializing c_int array by reading file

Hi all - Using a Python array, I can initialize a 32,487,834 integer array (found in a file HR.DAT) using the following (not perfectly Pythonic, of course) commands: F = open('HR.DAT','rb') HR = array('I',F.read()) F.close() I need to do the same in ctypes. So far the best I have is: HR = c_int * 32487834 I'm not sure how to initi...