arrays

Insert array contents into a string

Hello, I am trying to insert the contents of an array in to a string using PHP. My array ($array1) looks like this: Array1 ( [0] => http://www.example.com/1 [1] => http://www.example.com/2 ) I want to insert both links in to a coma separated string, so I can then insert it in to a database field. I tr...

How to use Array of C language with Objective-C

Hi. I'm using Objective-C language. But I don't know how to use c with Objective-C. Ex) This is Function method. - ( ?? ) function{ unsigned int first = .. unsigned int second = .. unsigned int third = .. int infoData = {first,second,third}; return infoData; } How to fill in parenthesis. I don't use NSArray. Please help me. ...

java - do while string is NOT null or empty

OK so here is some logic thinking... What I am trying to do is loop through strings until I hit a null/empty string.. then STOP. All while putting those strings inside a string array... Here is a sample of the code. I know it's wrong but hopefully to give you an idea of what I am trying to achieve: int i; wepN = new String[100]; int we...

How to point at the right key to get some value from array?

I have array data as shown below, I want to store 'sale' value into database if my currency are USD. Array ( [currency] => USD [sale] => 9120.00 [buy] => 8970.00 ) Array ( [currency] => SGD [sale] => 6653.75 [buy] => 6520.75 ) Array ( [currency] => HKD [sale] => 1173.40 [buy] => 1152.10 ) Array ( [currency] => CHF [sal...

jQuery .inArray question

I want to check if my row id is within in an array. If I set a fixed value to myindex it works but as it is below it always returns the FALSE value.Thank you. $('#stripeMeSubSubCat tr').each(function(){ myindex = $.trim($(this).closest("tr").attr("id")); var array = [ 0, 52, 53 ]; alert(myindex); alert(array); if ...

C++ - Memory issues with two dimensional array

Hi guys, Following this nice example I found, I was trying to create a function that dynamically generates a 2D grid (two dimensional array) of int values in C++. It works fairly well the first couple of times you change the values but if crashes after that. I guess the part where memory is freed doesn't work as it should. Any ideas w...

Catch undefined index in array and create it

<h1><?php echo $GLOBALS['translate']['About'] ?></h1> Notice: Undefined index: About in page.html on line 19 Is it possible to "catch" an undefined index so that I can create it (database lookup) & return it from my function and then perform echo ? ...

jQuery Array interpretation

I construct an array, which I am going to use later to compare some values. I use this code to construct "myArray", which I am going to use later: var optionTexts = []; $('#stripeMeSubSubCat tr').each(function(){ if ($(this).find('input:checkbox.subsubcat_chkclass:not(:checked)').length == 0) { subsubrow_cat_id_no = parseInt($(t...

using static dictionary as cache may lead to leak problem ?

hello all, I have memory leak in the web application (servlet) that I am working on. I am suspicious of 1 cause and wanted to hear your ideas about it. I use hashmaps,hashsets etc. as DB (about 20MB data loaded). These maps,sets get reloaded once in every 10 min. There are huge amount of simultaneous requests. I read that, GC passes ob...

Pathfinding in 2D Arrays

Let's say I have this 2D Array map { 0,0,0,0,7,1,1,1,1,1,1,1,1 }, { 0,7,7,7,7,1,1,1,24,1,1,1,1 }, { 0,7,24,24,24,24,24,24,24,1,1,3,1 }, { 0,7,23,23,23,23,23,23,24,1,1,3,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,24,23,23,23,23,23,23,1,1,1,1 }, { 0,7,23,23,23,23,23,23,24,1,3,1,1 }, { 0,7,24,24,24,24,24,24,24,1,3,1,1 }, { 0,0,0,0,1,...

How do I invert my array?

I have an array that i want to invert how do i do this? ...

Need PHP to sort files ALPHA and NUMERIC

I have a bit of PHP code that grabs a list of files from a directory, and puts them into an array. I can sort the array alphabetically, and the file list comes out like this: (Ex A) CC 2010.pdf CCP 2010.PDF RS 1 2010.PDF RS 15 2010.PDF RS 2 2010.PDF I want PHP to sort alphabetically but also take into consideration sorting files wit...

C: save received Winsock packet to file as hex

I need to do what most packet monitoring programs do (Wireshark, tcpdump, etc.). When data is received through Winsock, I just need to convert the packet to a hex representation and save it to file. The data is just a simple char array. I've tried lots of things like sprintf but with no luck. I also don't want to use itoa since it's no...

JSON array doesn't populate

For some reason the following JSON string creates the correct number of records in the custom objects array, but does NOT populate the objects in the array with and values. Help appreciated! JSON String { "Grids": [{ "CommitImporterGrid": {"CostDivisionCode": "DL", "CostDivisionKey": 5, "CostDivisionName": "Direct Labor", "SourceType...

sorting part of a multidimensional array

I have an multi dimensional array: $array[0] = array ( name => "Bob", position => "Chair", email => "[email protected]" ); $array[1] = array ( name => "Al", position => "", email => "[email protected]" ); //etc.. I want to sort it so that those whose position != "" are first, then the rest alphabetically by name... I'm not very fam...

Can I divide an array or string into multiple variables?

Here's where I've been: I made a PHP client call via soap to retrieve an array of data, I successfully receieved and converted my array to JSON via json_encode, I then echoed it back to my page. Here's where I am: I get back my array in this format... {"MethodName":"ID,11|1|Item1,22|2|Item2,33|3|Item3"} Here's where I want to be: Using...

while(list($key, $value) = each($array)) vs. foreach($array as $key => $value)?

Recently I experienced this weird problem: while(list($key, $value) = each($array)) was not listing all array values, where replacing it with... foreach($array as $key => $value) ...worked perfectly. And, I'm curious now.. what is the difference between those two? ...

Replacement of random string/char array characters using match ups.

while (1) { char j; if (x[j] == y[j]) Here I am trying to start a loop where I want to able to match any of the characters from char array 'x' with char array 'y'. If the characters do match from x to y then I want to keep them as they are and if they don't I want to be able to replace them with a star '*'. (e.i. x = [a,p,f] an...

Python csv string to array

Anyone know of a simple library or function to parse a csv encoded string and turn it into an array or dictionary? I don't think I want the built in csv module because in all the examples I've seen that takes filepaths, not strings. Thank you ...

How to use php function "array_diff_uassoc" in a class?

Here is a sample class: class A{ . . . public function updateAction(){ $tags=explode(' ',$taglist); . . . $tagsInDb=$tagsInDb->toArray(); $dif=array_diff_uassoc($tags,$tagsInDb,"here the callback should be inserted"); } protected function callback_function_for_arra...