If I have an array that looks like this:
$str = '';
if( $_POST['first'] )
$str = $_POST['first'];
if( $_POST['second'] )
$str .= ($str != '' ? ',' : '') . $_POST['second'];
if( $_POST['third'] )
$str .= ($str != '' ? ',' : '') . $_POST['third'];
if( $_POST['fourth'] )
$str .= ($str != '' ? ',' : '') . $_POST['second'];
$...
<input name="foo[]" ... >
I've used these before, but I'm wondering what it is called and if there is a specification for it?
I couldn't find it in the HTML 4.01 Spec and results in various Google results only call it an "array" along with many PHP examples of processing the form data.
...
Hi i am trying to generate a 5 digit int array in java and am having trouble on where to start. None of the numbers in the array can be duplicates. i can generate random numbers for it fine but just cant figure out how to compare the numbers to each other and replace any duplicates.
thanks
...
Hi there
I have to sum some arrays(an array of arrays). The structure of my arrays is like this:
Array([id]=>some_id, [name]=>some_name, [value]=>float_value)
I know that I have N arrays as the one before. I need to sum those with the same id.
any idea?
Example:
**
Array
(
[id] => 1
[name] => John00
[value] => 0.9
)
...
Dear all,
here's a very basic question, that I'm sure you will be able to answer quickly. Please don't laugh at my ignorance.
I have a string, that I want to compare to an array of strings. Only if the string is not part of the array, I want to perform an operation. I tried the following code, that doesn't work. I do understand why, bu...
I know that instantiated arrays of value types in C# are automatically populated with the default value of the type (eg false for bool, 0 for int, etc etc).
Is there a way to autopopulate an array with a seed value that's not the default? Either on creation or a built in method afterwards (I believe Java has something like Array.Fill() ...
Given the following function:
function process_pipes(text)
{
split(text,recs,"|");
for (field in recs){
printf ("|%s|\n", field)
}
}
If the input is: 0987654321|57300|ERROR account number not found|GDUMARESQ|0199|9|N|0||
Why do I get the numbers below instead of the text?
|4|
|5|
|6|
|7|
|8|
|9|
|10|
|1|
|2|
|3|...
char **Data[70]={NULL};
What is the correct terminology for this? How else could it be written? What does it look like in memory? I am reading many tutorials on pointers but I don't see it in this syntax. Any help is appreciated. Thanks.
...
Hi,
I have a List of users List<Users> and I need to make a javascript array of all the UserID's.
I know I can manually build this using a stringbuilder and loop through and then save it to a variable and show it on my asp.net-mvc view page.
Any other more creative ways to do this?
...
Hello,
I've tried to pass an initialization list {...} to a constructor and it didn't work.
When I instead declared it in a method local variable (int[]) it worked flawlessly.
Why is that?
public class QuickSort {
int[] a;
public QuickSort(int[] a) {
this.a = a;
}
public static void main(String[] args) {
//...
I use the following code to convert an object array to a string array :
Object Object_Array[]=new Object[100];
// ... get values in the Object_Array
String String_Array[]=new String[Object_Array.length];
for (int i=0;i<String_Array.length;i++) String_Array[i]=Object_Array[i].toString();
But I wonder if there is another way to do thi...
Is there any fast way to get all subarrays where a key value pair was found in a multidimensional array? I can't say how deep the array will be.
Simple example array:
$arr = array(0 => array(id=>1,name=>"cat 1"),
1 => array(id=>2,name=>"cat 2"),
2 => array(id=>3,name=>"cat 1")
);
When I search for key=name a...
I have a byte array that contains 6 bytes last 2 represents the port number while searching for a way two convert these last to bytes to a port number i have come across this snippet,
int port = 0;
port |= peerList[i+4]
port <<= 8;
port |= peerList[i+5]
it works but i need some clarification as to how it w...
I'd like to generate a number of objects (in C++) based on the amount/number the user enters.
Now I've somewhere heard that it has to be done using pointer tricks, creating a pointer to an array of the Object type required, and then dynamically increasing the size of array ( at runtime ).
Isn't there a workaround of directly using name...
I want to pass 2 arrays to a function in Java and have them sorted in the calling function. How do i use a function to accomplish that?
I could have the function return an object with 2 arrays, but is there a non object-oriented solution to this?
EDIT : I this particular situation I cant use the inbuilt Array.sort function in Java. ...
I'm starting to learn C by reading K&R and going through some of the exercises. After some struggling, I was finally able to complete exercise 1-19 with the code below:
/* reverse: reverse the character string s */
void reverse(char s[], int slen)
{
char tmp[slen];
int i, j;
i = 0;
j = slen - 2; /* skip '\0' and \n */
tm...
I would like to create an object array in C# of undefined length and then populate the array in a loop like so...
string[] splitWords = message.Split(new Char[] { ' ' });
Word[] words = new Word[];
int wordcount = 0;
foreach (string word in splitWords)
{
if (word == "") continue;
words[wordcount] = n...
Problem:
I have two arrays that can possibly be different lengths. I need to iterate through both arrays and find similarities, additions, and deletions.
What's the fastest and most efficient way to accomplish this in C#?
Edit:
The arrays are pre-sorted and they can contain anywhere between 50-100 items. Also, there aren't any const...
I need a multidimensional array of chars that is dynamic in only one dimension...
I have to store a pair of strings with a length of 10 (or less) chars each, but with a variable number of "pairs".
My idea was this
char (*instrucao)[2][10];
Which gives me a pointer to a 2x10 array of chars, but this is not working properly when i do s...
I have 2 separate arrays, one is just the id's the other is the percentage
Id's:
Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
}
Percent array:
Array
(
[0] => 28
[1] => 39
[2] => 17
[3] => 28
[4] => 23
So it would end up like:
Array
(
[0] => Array
(
[id] => 3
[percen...