arrays

why I still don't get an empty array?

Quoted from here: If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned. But why I still don't get an empty array? var_dump(explode(',', '', -1)) I get this: array(1) { [0]=> string(0) ""...

why I still don't get an empty array?

Possible Duplicate: why I still dont get an empty array? Quoted from here: If delimiter contains a value that is not contained in string and a negative limit is used, then an empty array will be returned, otherwise an array containing string will be returned. But why I still don't get an empty array? var_dump(ex...

extract data from NSMutableArray

In my application i parse a xml from which I get a list of items (hotels and restaurants) that i put into array "listElements"; I need to get from this array, another array that will contain only the particular elements (hotels only) and then I need to get from this array, three array that will contain hotels according to stars(array5sta...

Double free coruption

Hi, I have a class call grid. The class holds two 2d char arrays for storing a grid... The class has two functions for creating the memory for the grid and releasing the memory for the grid. Grid.h private: char **gridOne; char **gridTwo; Grid.cpp void Grid::allocateGridMem() { _gridOne = new char*[gridRowCount()]; _gridTwo =...

Overriding instance variable array’s operators in Ruby and scoping

I have a test class and a box class, in the test class i have a var called boxHolder, which is an array, i want to override the << method for this array. Inside the singleton how can i access moski_call ? class Test attr_accessor :boxHolder def initialize() super self.boxHolder = Array.new class << @boxHolder def <<...

HSQLDB and Array

Hsqldb 2.0 documentation talk about array and report this example: CREATE TABLE t (id INT PRIMARY KEY, scores INT ARRAY DEFAULT ARRAY[], names VARCHAR(20) ARRAY[10]) I tried it but I obtain this exception: [Error Code: -5581, SQL State: 42581] unexpected token: ARRAY How can I enable it? ...

compare arrays : one array is contained in the second array (key+value)

i want to check if one array is contained in the second array , but the same key and the same values, (not need to be equal, only check that all the key and value in one array is in the second) the simple thing that i do until now is : function checkSameValues($a, $b){ foreach($a as $k1 => $v1){ ...

choosing the element with more duplicates on an array in plain C

This question brings me back to my college days, but since I haven't coded since those days (more than 20 years ago) I am a bit rusty. Basically I have an array of 256 elements. there might be 1 element on the array, 14 or 256. This array contains the usernames of people requesting data from the system. I am trying to count the duplicat...

Declaring an array in C without giving size

When declaring an array like this: int array[][] = { {1,2,3}, {4,5,6}}; I get an error saying: "Array type has incomplete element type" What is going on?? ...

JS not pushing to array

Hey guys, Trying to push some coordinates, as well as some stuff specified in a form by the user, to an an array called "seatsArray". Here's my code: <div> <img onLoad="shiftzoom.add(this,{showcoords:true,relativecoords:true,zoom:100});" id="image" src="plan1.bmp" width="1024" height="768"> </div> <script type="text/javascript"> var s...

$.post variable as array with values?

hello - sending some data via post but want to send an array to but keep getting errors? excludes is the array i'm trying to send. $.post("/youradmin_v2/scripts/php/process.php", { funcName:'searchContent', table:'content', fields:'title,contentID', keyword:$(this).val(), ...

Determining three in a row in Python 2d array

Hey all- I'm working on a tic-tac-toe game with a M x N board in Python. I'm trying to find an efficient way to determine if a player has won (3 in a row either vertical, horizontal, or diagonal direction.) Most 3x3 implementations of the game just check for all possible winning combinations after each turn. This seems a little extre...

How to add more than one piece of data to an array follow the .each method

I have the following method: def speciate chem_formula.each { |chemical| @chem_species = chemical.scan(/[A-Z][^A-Z]*/) puts @chem_species } end that produces: H2 S O4 @chem_species = ["S", "O4"] from: @chem_formula = ["H2" "SO4"] How do you set the array to include all iterations? That is how do you output ["H2", "S"...

How can I use an NSArray as a global constant?

I'm using a set of Constant.m files, one per target, to define specific things for each target. For example: // Constants.h extern NSString * const kDatabaseFileName; //Constants.m NSString * const kDatabaseFileName = @"target_one.sqlite"; I'd also like to define an NSArray for each of my targets: NSArray * const kLabelNames = [[NSAr...

How to release objects stored in an array?

Please look at the code below and suggest the best approach. I can't quite tell whether the code is correct. When adding objects to arrays, do they get a retain count? In the second function, am I releasing the local variable "mySubview" or the original object? // this is a class property myArray = [[NSMutableArray alloc] init]...

WordPress: How to merge custom post type array?

Hello, i try to setup a yearly (grouped by month) archive for custom post types in WordPress. But my code did not work as aspected. Maybe it is obiviously for someone who is more familar with WordPress and PHP but i can't get it work. The code below is grouping by month but each post type by itself. Maybe i need to merge booth. But how...

can't convert Array into Integer

I'm trying to iterate through an array, @chem_species = ["H2", "S", "O4"] and multiply a constant times the amount of constants present: H = 1.01 * 2, S = 32.1 * 1 and so on. The constants are of course defined within the class, before the instance method. The code I've constructed to do this does not function: def fw x = @chem_specie...

Pass values from array to object? - PHP

My problem, simplified is: class A { public $a; public $b; function f1 () { // Code } } $obj = new A(); $arr = array ("a" => 1, "b" => 2); How can I put the contents of $arr into $obj? (Obviously without $obj->a = $arr["a"], suppose there are thousands of values) Thank you. ...

Make first every first character uppercase in array

Hi! I'm trying to get all my first characters in a PHP array to be uppercase. PHP code: <?php $ordlista = file_get_contents('C:/wamp/www/bilder/filmlista.txt'); $ord = explode("\n", $ordlista); sort($ord,SORT_STRING); foreach ($ord as $key => $val) { echo $val."<br/>"; } ?> Thanks ahead for answers! Solved: <?php $ordlista ...

Checkbox to SQL Database

I have a problem which I'm struggling to fix. I have a form with many checkboxes containing email addresses, the result of which is sent to another page. This page will send out newsletters. This is working at the moment, but what I would like to do is include their name. From the form received I get the results ([email protected], [email protected]...