arrays

fix problem hebrew on Facebook

hi guys, i have code that know how to connect to user facebook account,and take his name. this function does works well, the problem is , when i try to get hebrew name, than i get gibrish. charset=windows-1255 - i tried UTF-8 too, and still i have gibrish. for gibrish example: ׳׳™׳˜׳ ׳§׳•׳•׳ ׳– the code: require 'src/facebook.php'; ...

Putting comma(,) at end of array.Is it a convention?

Hi, Sometimes I see arrays like the following: array('item1' => array( 'subitem1', 'subitem2', ) Why a comma is added at end of array wheras there is not any element after submitem2? ...

PHP remove values from a single array?

Possible Duplicate: How to remove duplicate values from an array in PHP How can I remove all multiple values for example 55,55 will only be 55 using PHP Example 1 Array ( [0] => 9 [1] => 2 [2] => 55 [3] => 55 [4] => 9 ) Example 1 should look like example 2 below. Array ( [0] => 9 [1] => 2 [...

Looking through an array of objects

I'm trying to write a method that looks through an array of objects for a certain color, which is also an object. public Ghost findFirst(Color c){ for (int i=0;i<ghosts.length;i++) { if (ghosts[i].getColor()==c) return ghosts[i]; else return null; } } So if the col...

Assigning an address to a struct pointer array member in C.

Having considerable trouble with some pointer arithmatic. I think I get the concepts (pointer variables point to a memory address, normal variables point to data) but I believe my problem is with the syntax (*, &, (*), *(), etc.) What I want to do is build dynamic arrays of a custom struct (i.e. arrays of pointers to heap structs), and ...

Creating a deep copy method, Java

I want to make a deep copy method. I seeked help here the other day with this issue, but that was for a copy constructor. Now I need a regular method. I have the code created (nonworking), but I'm just not understanding it completely. public GhostList deepCopy(){ int length=this.getLength(); GhostList jadeed=new GhostLis...

Order/randomize/convert array in rails

Hi, I've got this: a = [[123,1],[124,1],[125,1],[126,2],[127,3],[128,3]] And I would like to turn a into b: ordered by value random within array of value // updated: b = [[124,123,125],[126],[128,127]] How to do this in ruby? Im using rails. ...

Comparing two objects using an equals method, Java

I have an array of objects that I want to compare to a target object. I want to return the number of objects that exactly match the target object. Here is my count method: public int countMatchingGhosts(Ghost target) { int count=0; for (int i=0;i<ghosts.length;i++){ if (ghosts[i].equals(target)); ...

Arrays and ListView in Android

I have a ListView that displays every item in an array called, "Facts_Array". What I would like to do is display the count of the item clicked on. Right now I have this: lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view,int position, long id) { Toast.ma...

PHP array parsing

I am wondering if there are any classes for parsing PHP arrays in the general sense that you are looking back and forth over elements matching search patterns. For example, lets say that If element "xyz" was found then I want to search backwards through the array until element "abc" or "cba" is found (or X number of steps backward is re...

How do make an array that fits string from stdin?

I am trying to use 'gethostbyname'. If I hardcode a host name directly into the function call it works great. However, I am trying to pass user input into this function. I believe my problem may because the array I am passing to the function has many trailing whitespaces. void connectHost(char *hostname) { int n; //This ...

Easy Java Array Question

Given: an int variable k , an int array currentMembers that has been declared and initialized, an int variable memberID that has been initialized, and an boolean variable isAMember , write code that assigns true to isAMember if the value of memberID can be found in currentMembers , and that assigns false to `is...

PHP array vs mysql query

Hello, I am working on an authorization script that checks for user name, password and access level (roles). It works fine as long as there is only one role to check. I would like to learn how I can put the roles into an array and have the database check if any of them are present in the database for the logged in user. Right now it on...

Java Array, Finding Duplicates

I have an array, and am looking for duplicates. duplicates=false; for (j=0;j<zipcodeList.length;j++) for (k=0;k<zipcodeList.length;k++) if (zipcodeList[k]==zipcodeList[j]){ duplicates=true; } However, this code doesnt work when there are no duplicates. Whys that? ...

Search an Array Android

I have a textbox and search button, now all I need is the code to implement searching an array. The array I have is called Facts_Array (consists of strings). Comment if you need any more information. ...

Looking through an array for an empty string

An array of Strings, names, has been declared and initialized. Write the statements needed to determine whether any of the the array elements are null or refer to the empty String. Set the variable hasEmpty to true if any elements are null or empty-- otherwise set it to false. hasEmpty=false; for (int i=0;i<names.length;i++) i...

Is accessing an array is faster than accessing vector ?

Possible Duplicates: Using arrays or std::vectors in C++, what's the performance gap? std::vector is so much slower than plain arrays? memory is vector of 1000 elements array[] is an integer array of 1000 elements for (iteration = 0; iteration < numiterations; iteration++) { for (j = 1; j < numints; j++) { memory...

How to create an Haskell array from a function

For caching purposes, I want to create an array, which maps input values of the function to output values. I know, that my function will be used only in this specific range, I think about something like this: MyType = ... deriving (Ix) myFunction :: MyType -> foo myCache = createArrayFromFunction (start,end) myFunction Is this poss...

How can I efficiently convert a large decimal array into a binary array in MATLAB?

Here's the code I am using now, where decimal1 is an array of decimal values, and B is the number of bits in binary for each value: for (i = 0:1:length(decimal1)-1) out = dec2binvec(decimal1(i+1),B); for (j = 0:B-1) bit_stream(B*i+j+1) = out(B-j); end end The code works, but it takes a long time if the length of th...

Copying value from char pointer to a char array

I am having a pointer *ip_address_server which holds the ip address of the server : in_addr * address = (in_addr * )record->h_addr; char *ip_address_server = inet_ntoa(* address); Clearly, when I use printf to print the value of it, it gets nicely printed. printf("p address %s" , ip_address_server); But now if I declare...