arrays

Objective-C return enum array from method

I have an enum in my objective-C code similar to this: typedef enum { FRUIT_APPLE = 1, FRUIT_PEAR = 2, FRUIT_BANANA = 3, // etc. } Fruit I need to be able to return an array of these in a method, something like this: @implementation FruitTest static Fruit fruits[] = {FRUIT_APPLE, FRUIT_BANANA}; +(Fruit[]) fruits { ...

Search through a string for any one of the items in an Array

Here's my search array: $aExt = array('png','jpg','gif'); I want to search through the variable: $sIcon How can I search if the variable includes anything in this array using PHP? It's like in inverted in_array: strstr($sIcon, $aExt) <- Can second arg be an array? ...

Accessing associative arrays in PHP

Hello, I want to access the index 'memo' in the associative array in PHP below $variables["thelistitems"]; print_r($variables["thelistitems"]); Output Array ( [0] => Array ( [productid] => prod:c6dbdd62-dc13-6421-5a94-c8cd871a59d3 [memo] => dummy [taxable] => 0 [unitweight] => 0 [u...

How to find item in array using jQuery?

So I have this array: var statuses = { New:1, Addressed:2, Rejected:3, Recovered:4, Billed:5, Completed:6 }; And I'd like to basically search the array for the "Rejected" key and have it return the value, so I can then go back/forth in the array as needed. I've tried this, but it always fails with a "-1" saying it can't find it. jQu...

Javascript - Extract text from a page then build an array with it

I have a table of data that I want to grab text from, stick into an array (and then use with Google maps). The table looks like: <table> <thead> <tr> <th>One</th> <th>Two</th> </tr> </thead> <tr class='bar'> <td class='name'>Bob</td> <td class='number'>12345</td> </tr> <tr class='bar'> <td clas...

How can I determine if there are unassigned values remaining in an array?

I have a standard java array, where null values are used for unassigned or empty spots in the array. How can I tell if there are unassigned values left, i.e. if the array is not full? ...

referring to arrays as pointers

Hi.. I can't seem to understand the difference between the different declarations on an array or a 2d array. for instance: void swap(char **a, char **b) { char *t = *a; *a = *b; *b = t; } int main(int argc, char **argv) { char a[] = "asher"; char b[] = "saban"; swap(&a,&b); } this code doesn't compile, it outp...

Splitting string into an array in PHP

Hello, I want split a string which consists of products. Each product is encloded within {..}, and separated by comma. For instance, I have a strin below. [ {\"productid\" : \"prod:kj42j3d24-47c2-234lkj2-e3c2-cfc9a4a3b005\",\"memo\" : \" product description \",\"taxable\" : 0,\"unitweight\" : 0,\"unitcost\" : 0,\"unitprice\" : 12.34,...

ReDim an Array Pointer VB6

Hi guys, I'm trying to ReDim a member object array from a different class. For example: Class1.cls Dim mStuffArray() As New clsStuff Property Get StuffArray() As clsStuff() StuffArray = mStuffArray End Property Class2.cls Private Sub Foo(ByRef pClass1 As Class1) Dim tStuffArray() As clsStuff tStuffArray = pClass1.Stuf...

C++ fill array with objects derived from array type

In C++ I have an array of pointers to Player objects and want to fill it with Fickle objects where Fickle is a class that is derived from Player. This is because I want a general Player array that I can fill with different objects from different classes that all are derived from the Player class. How can I do this? I create an array o...

How can I define an arbitrarily-sized 2D array and then determine its dimensions at compile-time?

Executive summary: How can I define an arbitrarily-sized 2D array in C? How can I determine the dimensions of that array at compile-time? Full disclosure: I'm writing code for an embedded controller. My application requires several lookup tables with different sizes which will all be used by one lookup function (a binary search). He...

What is the most versatile array to string serialization method?

I'm particularly interested in the following features: possibility of modifying the serialized array using regular expressions or other simple methods, being able to parse the string using standard tools in various programming languages, serialization of simple arrays as well as associative arrays (objects), conciseness and human reada...

Reversing elements of an array-Java

Given an array a and two other int variables, k and temp , write a loop that reverses the elements of the array. for(k=0;k<a.length-1;k++){ temp=a[k]; a[k]=a[a.length-1-k]; a[a.length-1-k]=temp; } This is not working. Any idea why? ...

array question - what does this line do?

package javaapplication1; import java.io.*; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { NotSimple[] objArray; BufferedReader stdin = new BufferedReader( ...

C++ equivalent to Java's System.arraycopy

I'm a Java programmer and have recently needed to start coding in C++. I'm trying to port some Java code of mine that makes heavy use of the System.arraycopy method and want to know if there is an equivalent in C++. Basically I want to have n byte arrays and combine them into one big array. Each of the initial arrays can be of variabl...

Can you add a number to a number in a Array?

package javaapplication1; import java.io.*; /** * * @author simon */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) throws IOException { NotSimple[] objArray; BufferedReader stdin = new BufferedReader( ...

jQuery: dupe check function for array

hi, i'm having a global array which holds my css+js includes and i'm looking for the easiest solution for the following issue: a function which allows adding more includes (as string) - eg. addIncludes("script1.js,script2.js,style1.css,style2.css"); that function should automatically filter duplicate entries example: var myIncludes...

jquery ajax array response handling

How to handle a array response from .getjson. Following code handles ajax request. function getinfo() { $query="select field_uname_value,field_uaddress_value,field_uphone_value from {content_type_udetails}"; $result= db_query($query); $i=0; while($item = db_fetch_object($result)) { $info[$i++]=array...

How to access the first character of a character array?

#include <stdio.h> int main(void){ char x [] = "hello world."; printf("%s \n", &x[0]); return 0; } The above code prints out "hello world." How would i print out just "h"? Shouldn't the access x[0] ensure this? ...

Java: Change String[][] Dynamically

I have this code: newArray = new String[][]{{"Me","123"},{"You","321"},{"He","221"}}; And I want to do this dynamically. Add more elements, things like it. How do I do this? PS: Without using Vector, just using String[][]; ...