This question is related to the post here. Is it possible to initialize an array in a function call or constructor call? For example, class foo's constructor wants an array of size 3, so I want to call foo( { 0, 0, 0 } ). I've tried this, and it does not work. I'd like to be able to initialize objects of type foo in other objects' constr...
Now comes the hard part. How do you optimize this function:
function coin_matrix($test, $revs) {
$coin = array();
for ($i = 0; $i < count($test); $i++) {
foreach ($revs as $j => $rev) {
foreach ($revs as $k => $rev) {
if ($j != $k &&
$test[$i][$j] != null &&
$tes...
I am required (please therefore no nit-picking the requirement, I've already nit-picked it, and this is the req) to convert certain form fields that have "object nesting" embedded in the field names, back to the object(s) themselves. Below are some typical form field names:
phones_0_patientPhoneTypeId
phones_0_phone
phones_1_patientPh...
Pretty basic programming question, I know PHP have a function for it, but does the iPhone OS have one?
I want to check if the current indexPath is a value in an array.
PHP Example:
<?php
$indexPath = 3;
$array = array("0", "1", "2", "3", "4");
if (in_array($indexPath, $array)) {
// Do something
}
?>
Does anybody know how to do the...
Hi
I have an array that I would like to sort using a date field from a MySQL database.
Here is a sample of the array which is named news in my class:
[48] => Array
(
[id] => 14
[type] => 3
[updated] => 2010-04-17 13:54:42
)
[49] => Array
(
[id] => 15
[type] => 3
[updated] =...
Sometimes, when I submit a form that gathers checkbox data, the checkbox data displays perfectly and other times, the values don't display at all. Any ideas what could cause this?
...
So I'm working on a website with Doctrine as ORM and I get the following array back as a result:
Array (
[0] => Array (
[c_cat_id] => 1
[c_title] => Programas e projetos
[p_menu] => PBA BR 163
[p_page_id] => 1
)
[1] => Array (
[c_cat_id] => 1
[c_title] => Programas e projetos
...
I have an array being returned from the database that looks like so:
$data = array(201 => array('description' => blah, 'hours' => 0),
222 => array('description' => feh, 'hours' => 0);
In the next bit of code, I'm using a foreach and checking the for the key in another table. If the next query returns data, I want to upd...
I have a file in which every line is an integer which represents an id. What I want to do is just check whether some specific ids are in this list.
But the code didn't work. It never tells me it exists even if 123 is a line in that file. I don't know why? Help appreciated.
open (FILE, "list.txt") or die ("unable to open !");
my @da...
What is a quick, elegant way of using MatLab to form a subarray around a particular element? Element are selected randomly from the data, so you can't take a subarray in the normal way (it has to be generalized for the elements that are selected). What I mean is, forming an array for example 5x5 or 7x7 or something, where the middle elem...
Basically, this is what I currently use in an included file:
$sites[0]['url'] = "http://example0.com";
$sites[1]['url'] = "http://example1.com";
$sites[2]['url'] = "http://example2.com";
$sites[3]['url'] = "http://example3.com";
$sites[4]['url'] = "http://example4.com";
$sites[5]['url'] = "http://example5.com";
...
I am parsing an arbitrary length byte array that is going to be passed around to a few different layers of parsing. Each parser creates a Header and a Packet payload just like any ordinary encapsulation. And my problem lies in how the encapsulation holds its packet byte array payload. Say i have a 100 byte array, and it has 3 levels of e...
I have an array of numbers:
@numbers = 1,2,3,6,8,9,11,12,13,14,15,20
and I want to print it this way:
1-3,6,8-9,11-15,20
Any thoughts? Of course I tried using the most common "looping", but still didn't get it.
...
I inherited a zencart mod and can't figure out what's wrong. The customer selects a product and an attribute (model#). This is then sent to another form that they complete. When they submit the form, the product and the attribute should be included in the email sent.
At this time, only the product is coming through. The attribute just s...
Hi,
I want to copy an int array to another int array. They use the same define for length so they'll always be of the same length.
What are the pros/cons of the following two alternatives of the size parameter to memcpy()?
memcpy(dst, src, ARRAY_LENGTH*sizeof(int));
or
memcpy(dst, src, sizeof(dst));
Will the second option always ...
I have a Array
string[] names = { "Jim Rand", "Barry Williams", "Nicole Dyne", "Peter Levitt", "Jane Jones", "Cathy Hortings"};
Is there any way to find which is the shortest(Length wise) element in this array and then store rest of elements in a different array.
Thanks,
Ani
...
Hi,
I am writing a function that takes a string, string pointer and an int.
The function splits the string based on a set of rules and puts each token into an array. I need to return the array out of the function with the number of elements in the int variable etc. I am stuck as to how I return the array as I can not use auto other wise...
Hello. I have some String[] arrays, for example:
['a1', 'a2']
['b1', 'b2', 'b3', 'b4']
['c1']
How can I mix them, so that I get ['a1', 'b1', 'c1', 'a2', 'b2', 'b3', 'b4'] (0 element of a, then b, c, 1 element of a, b, c and so on)? Thanks
More accurately the resulting array must consist of the first value of the first array, then the...
I've got two (or more) arrays with 12 integers in each (corresponding to values for each month). All I want is to add them together so that I've got a single array with summed values for each month. Here's an example with three values:
[1,2,3] and [4,5,6] => [5,7,9]
The best I could come up with was:
[[1,2,3],[4,5,6]].transpose.map{|ar...
What I want to do: Create a game that starts with 3 green dots on the left and 3 red dots on the right with a space between them. The endgame should have the colors switched sid*e. The rules of the game* is that, if there is a space next to a dot it should be able to move there, also if an opposite color is next to it - it should be able...