arrays

What's the easiest go to use dynamic array in c/c++ in windows xp?

I need to save instances of type HANDLE to an array container and iterate over it, finally remove some of them when necessary, Which container should I use for the purpose of easiness? ...

How would I use a hash slice to initialize a hash stored in a data structure?

In an earlier question I asked how to initialize a Perl hash using slices. It is done like this: my %hash = (); my @fields = ('currency_symbol', 'currency_name'); my @array = ('BRL','Real'); @hash{@fields} = @array; Now let's imagine a more complex hash, and here is how it is initialized: my %hash = (); my $iso = 'BR'; $hash->{$iso}-...

Add string to char array in C

I have a C array called buf. Here is it's definition: char buf[1024]; Now, my current code takes from stdin and uses fgets() to set that array, however I wish to use code to set it instead. Right now the line that sets buf looks like this: fgets(buf, 1024, stdin); Basically, I want to replace stdin, with say... "My String". What's th...

Dynamic Menu System

I am working on a dynamic menu system as the site I'm build has a strict naming convention. For example, if I have a script are named AboutUs.php, then 'About Us' will be a Parent Menu Item. However if I have a script named Product.Product1.php then 'Product' is the Parent Item with 'Product1' as the Sub Menu Item. The idea is to loop ...

Fastest way to process this array using PHP

I am looking to go from: array($ID => array (name => $name, created => $timestamp)) e.g [5632][name] = martin [5632][created] = 131232342 [6742][name] = paul [6742][created] = 131232312 [6321][name] = peter [6321][created] = 131232311 to an array of ids ordered by creation like [0] = 6321 [1] = 6742 [2] = 5632 What is the fastes...

How to pass multidimensional in URL with php

I want to know the way of passing multidimensional in URL with php. I have an array like this $number = $_SESSION["number"]; $number = $number+1; $_SESSION["number"] = $number; $_SESSION['count']$number]=array($_POST['buy_app_page'],$_POST['x'],$_POST['y'],$_POST['w'],$_POST['h'],$_POST['selected_values'],$number); $pixels_detail...

A simple solution to a PHP array problem is needed?

Hello, I actually am quite embarrassed to ask such a question but it is one of those days that you spend 10 thousand hours on the simplest of functions and the more you try to solve them the more complicated a solution you get.... I don't want to waste more time so here is the problem. I have one array: $items=array( 0=> array('...

More concise way to check to see if an array contains only numbers (integers)

How do you verify an array contains only values that are integers? I'd like to be able to check an array and end up with a boolean value of true if the array contains only integers and false if there are any other characters in the array. I know I can loop through the array and check each element individually and return true or false de...

How to get content from array

I'm total newbie to PHP and Drupal but I fix this simple(?) thingo on my template. I want to get title, date, text and link path from this array? I can't get it out of there. I think its because its in inside of another array and because im noob in PHP I cant get it out of there ? Also I would like to get it to a loop. If theres more con...

Global array in C header?

Okay, strange question time! I'm refactoring some old C++ code that declares a bunch of arrays like so: static SomeStruct SomeStructArray[] = { {1, 2, 3}, {4, 5, 6}, {NULL, 0, 0} } And so forth. These are scattered about in the source files, and are used right where they're declared. However, I would like to move them in...

PHP & MySQL - Echo a List of Strings

Hello everyone, I am kind of stumped on the idea of echoing a list of strings from a mysql server. How would the process go? The format I want it to be is like this: Name 1 Name 2 Name 3 Name 4 However each new name is in a new cell, and I don't know how to gather every single name from the mysql server. PHP is a very new language fo...

using jquery, how would i find the closest match in an array, to a specified number

using jquery, how would i find the closest match in an array, to a specified number For example, you've got an array like this: 1, 3, 8, 10, 13, ... What number is closest to 4? 4 would return 3 2 would return 3 5 would return 3 6 would return 8 ive seen this done in many different languages, but not in jquery, is this possible to d...

Grabbing specific values from a multi-dimensional array in PHP

Hi there, I'm new to programming and I'm tackling arrays. I thought I had multi-dimensional arrays figured out but I guess I don't. Here's the code I'm working on: $loopcounter = 0; while ($myrow = mysql_fetch_array($results)) { //...other stuff happens... $allminmax[$loopcounter][] = array("$myrow[3]","$currentcoltype","$tempmin",...

Syntax for pointer to portion of multi-dimensional statically-allocated array

Okay, I have a multi-dimensional array which is statically-allocated. I'd very much like to get a pointer to a portion of it and use that pointer to access the rest of it. Basically, I'd like to be able to do something like this: #include <stdio.h> #include <string.h> #define DIM1 4 #define DIM2 4 #define DIM3 8 #define DIM4 64 static...

Array of Sockets

I had a quick question on how i would maintain a connection of 1000 sockets. Im using threads to initiate writing and reading of the streams. However when I pass the socket to the new thread, the thread won't exit after excecution. I wanted to know if passing the socket would keep the thread on because it was still connected. ...

PHP - Add String to Array

Hello everyone, I am wondering how I can add a string variable to the current array. For example, I have an array called $finalarray. Then I have a loop that adds a value on every run. Basically: $finalarray = $results_array + string; A very basic structure. I am using this for MySQL so that I can retrieve the final array of the colu...

Piglatin using Arrays

Last night I was messing around with Piglatin using Arrays and found out I could not reverse the process. How would I shift the phrase and take out the Char's "a" and "y" at the end of the word and return the original word in the phrase. For instance if I entered "piggy" it would come out as "iggypay" shifting the word piggy so "p" is a...

How to modify the key of an array this way in PHP?

From the 2nd element in $array, increment the key by 100, suppose the keys are all numeric. ...

How to make an array element the first entry in PHP?

$arr = explode(',', $str); $arr[0] = 'Please select value'; The above makes key 0 the last element ,how to make it first except sort the $arr ? ...

ReleaseIntArrayElements, windows 7

Hi, I wrote simple java program which is calling jni function written in c. Java through native function pass int array, native function made some changes and then call release jni function. In windows xp everything is working fine, but in windows 7 x64 java vm crash on ReleaseIntArrayElements. carr = (*env)->GetIntArrayElements(env, a...