arrays

Return an array in c

Hello, I would like to know if there is any way to return an char array. I tried something like this "char[] fun()" but I am getting error. I don't want a pointer solution. Thanks! ...

How to search through subarrays efficiently in PHP?

$arr = array($arr1,$arr2,..); How to search through $arr to find the one with key1 => 'something',key2 => 'something else' ...

How to merge arrays but no numerical keys in fewest lines in php?

$result = array_merge($arr1,$arr2); I want to exclude numerical values of $arr2,is there an option for this? Edit after comment: $arr1 = array('key' => 1); $arr2 = array('test',1 => 'test', 'key2' => 2); after processing I need the result to be: array('key' => 1,'key2' => 2); Excluding numerical keys ...

Working with Delicious API json response...

When I try to find out the total count of delicious bookmarks, Delicious returns a json file which when decoded is: Array ( [0] => stdClass Object ( [hash] => e60558db2d649c8a1933d50f9e5b199a [title] => ISRAEL: Thousands march in Jerusalem rally, Israel still kicking new families out of lan...

VBS Runtime error 800A000D - Type mismatch

I am trying to run a .VBS script from Windows Explorer (IIS Manager 6) and am a novice VBScript programming. I am getting above error when running the following code. What am I doing wrong? I just need to generate the IIS MIME types please! Error detail: Line 49, char 5; where line 49: MimeMapArray = MimeMapObj.GetEx("MimeMap") Cod...

How to sum up an array of integers in C#

Is there a better shorter way than iterating over the array? int[] arr = new int[] { 1, 2, 3 }; int sum = 0; for (int i = 0; i < arr.Length; i++) { sum += arr[i]; } clarification: Better primary means cleaner code but hints on performance improvement are also welcome. (Like already mentioned: splitting large arrays). It's no...

"Fatal error: Cannot use string offset as an array" when variable is 08 or 09.

I'm writing a script to output Google Analytics API data and insert it into a bar chart using Google Charts API. When I have a string like this in the URL, I get the desired result. gaFeedData.php?y[]=2009&y[]=2010&m[]=1&m[]=2 However, when I have the following string in the URL, I get an error: Fatal error: Cannot use string offset ...

PHP Array trim blank index values

How to trim a PHP array and remove all empty indexes Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => 4 [8] => 6 [9] => ) Output should be like Array ( [0] => 4 [1] => 6 ) ...

Display list of values separated by commas without trailing comma

I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines table and a mapping/link table Service_lineToSubcontracts which contains the subcontract_id and service_line_id. On the subcontract view, I'd like to list the corresponding service lines. This works, but has a trailing comma. <% foreach (var sls i...

Create a re-sizable array of CGPoints in objective-c

Hi I am trying to create a re-sizable array of CGPoints in objective-c. I've have looked into using NSMutableArray however it doesnt seem to allow resizing. Is there something else I can use? thank you ...

get an array variable in python

hi, can I do this in a loop, by producing the file name from the name of the array to store ? ab = array.array('B', map( operator.xor, a, b ) ) f1 = open('ab', 'wb') ab.tofile(f1) f1.close ac = array.array('B', map( operator.xor, a, c ) ) f1 = open('ac', 'wb') ac.tofile(f1) f1.close ad = array.array('B', map( operator.xor, a, d ) ) f1 ...

Combine two arrays on a key

I have two arrays: $course = Array ( [6] => 24 [0] => 20 [1] => 14 ) // etc With the key being the link to the next array: Array ( [0] => Array ( [course_id] => 1 [course_name] => Appetizer ) [1] => Array ( [course_id] => 2 [course_name] => Breakfast ) ) //etc I basically want to add the course_name to the first array ...

Write to javascript array within php loop

I have a php loop that is echoing out geolocation values. How can I get it to write those values to a javascript array, so I can then use them to plot points on an HTML5 canvas? The php loop is as follows <ul id = "geo-list"> <?php foreach($data as $phrase) { ?> <li><?php if ($phrase->geo != false) { ...

C++ - Access array (in main) from methods outside main

I have an array in my main class that holds objects that I need to print out for a menu listing. The array is declared and initialized in main. I need to, however, access the same array in a sub-menu function. If I copy the code (for loop that prints out the values) to the sub-menu, nothing is printed (presumably because it can't access ...

How to pass an array in AS3 to an array in php?

Hello friends, I have the following array as3 example: var arrayDefinitionsargsAmfPhp:Array = new Array(); arrayDefinitionsargsAmfPhp['tabela'] = "controls"; arrayDefinitionsargsAmfPhp['width'] = "100"; sending him to the remote object for php, example: async = bridge.getOperation(amfphpFunction).send(arrayDefinitionsargsAmfPhp); I...

file reading into array

I am trying to read contents of a file using string tokenizer and store all the tokens in an array but i keep getting exception in main error. I need advise on how to do this.Below is the code am using for that; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.Read...

Converting arrays into another format (PHP)

Hi.. i want to convert this array Array ( [2] => Array ( ) [4] => Array ( [12] => Array ( ) [13] => Array ( [16] => Array ( ) ) ) [5] => Array ...

Finding first available ID from an array

Hi, Given an array like this: Array => ( [0] => 1, [1] => 2, [2] => 3, [3] => 5, [4] => 6 ) What is the easiest way to find the first 'available' ID in that array that is, the first value in the sequence [1,2,3...n] that does not exist in the array? In this case, the correct answer would be 4. I can do this using some whi...

MATLAB: comparing all elements in three arrays

I have three 1-d arrays where elements are some values and I want to compare every element in one array to all elements in other two. For example: a=[2,4,6,8,12] b=[1,3,5,9,10] c=[3,5,8,11,15] I want to know if there are same values in different arrays (in this case there are 3,5,8) ...

Noob pointer/array question

I know this is probably a stupid question, but I need to be sure; I came accross some legacy code that contains a function like this: LPCTSTR returnString() { char buffer[50000]; LPCTSTR t; /*Some code here that copies some string into buffer*/ t = buffer; return t; } Now, I strongly suspect that this is wrong. ...